Merge branch 'master' into config-file-permission-mode

This commit is contained in:
黄润豪 2021-08-03 16:35:38 +08:00 committed by GitHub
commit 4a2c27a8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 25 deletions

View File

@ -24,4 +24,4 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
DOMESTIC_DOCKER_USERNAME: ${{ secrets.DOMESTIC_DOCKER_USERNAME }}
run: VERSION=v5.3.2-release ./release.sh all push
run: VERSION=v5.3.3-release ./release.sh all push

View File

@ -68,9 +68,11 @@ func (t *TenantStruct) StartService(w http.ResponseWriter, r *http.Request) {
tenant := r.Context().Value(ctxutil.ContextKey("tenant")).(*dbmodel.Tenants)
service := r.Context().Value(ctxutil.ContextKey("service")).(*dbmodel.TenantServices)
sEvent := r.Context().Value(ctxutil.ContextKey("event")).(*dbmodel.ServiceEvent)
if err := handler.CheckTenantResource(r.Context(), tenant, service.Replicas*service.ContainerMemory); err != nil {
httputil.ReturnResNotEnough(r, w, sEvent.EventID, err.Error())
return
if service.Kind != "third_party" {
if err := handler.CheckTenantResource(r.Context(), tenant, service.Replicas*service.ContainerMemory); err != nil {
httputil.ReturnResNotEnough(r, w, sEvent.EventID, err.Error())
return
}
}
startStopStruct := &api_model.StartStopStruct{
@ -84,7 +86,6 @@ func (t *TenantStruct) StartService(w http.ResponseWriter, r *http.Request) {
return
}
httputil.ReturnSuccess(r, w, sEvent)
return
}
//StopService StopService
@ -177,7 +178,6 @@ func (t *TenantStruct) RestartService(w http.ResponseWriter, r *http.Request) {
return
}
httputil.ReturnSuccess(r, w, sEvent)
return
}
//VerticalService VerticalService
@ -213,23 +213,23 @@ func (t *TenantStruct) VerticalService(w http.ResponseWriter, r *http.Request) {
tenantID := r.Context().Value(ctxutil.ContextKey("tenant_id")).(string)
serviceID := r.Context().Value(ctxutil.ContextKey("service_id")).(string)
sEvent := r.Context().Value(ctxutil.ContextKey("event")).(*dbmodel.ServiceEvent)
var cpu_set, gpu_set, memory_set *int
var cpuSet, gpuSet, memorySet *int
if cpu, ok := data["container_cpu"].(float64); ok {
cpu_int := int(cpu)
cpu_set = &cpu_int
cpuInt := int(cpu)
cpuSet = &cpuInt
}
if memory, ok := data["container_memory"].(float64); ok {
memory_int := int(memory)
memory_set = &memory_int
memoryInt := int(memory)
memorySet = &memoryInt
}
if gpu, ok := data["container_gpu"].(float64); ok {
gpu_int := int(gpu)
gpu_set = &gpu_int
gpuInt := int(gpu)
gpuSet = &gpuInt
}
tenant := r.Context().Value(ctxutil.ContextKey("tenant")).(*dbmodel.Tenants)
service := r.Context().Value(ctxutil.ContextKey("service")).(*dbmodel.TenantServices)
if memory_set != nil {
if err := handler.CheckTenantResource(r.Context(), tenant, service.Replicas*(*memory_set)); err != nil {
if memorySet != nil {
if err := handler.CheckTenantResource(r.Context(), tenant, service.Replicas*(*memorySet)); err != nil {
httputil.ReturnResNotEnough(r, w, sEvent.EventID, err.Error())
return
}
@ -238,9 +238,9 @@ func (t *TenantStruct) VerticalService(w http.ResponseWriter, r *http.Request) {
TenantID: tenantID,
ServiceID: serviceID,
EventID: sEvent.EventID,
ContainerCPU: cpu_set,
ContainerMemory: memory_set,
ContainerGPU: gpu_set,
ContainerCPU: cpuSet,
ContainerMemory: memorySet,
ContainerGPU: gpuSet,
}
if err := handler.GetServiceManager().ServiceVertical(r.Context(), verticalTask); err != nil {
httputil.ReturnError(r, w, 500, fmt.Sprintf("service vertical error. %v", err))
@ -475,7 +475,7 @@ func (t *TenantStruct) GetDeployVersion(w http.ResponseWriter, r *http.Request)
return
}
if err == gorm.ErrRecordNotFound {
httputil.ReturnError(r, w, 404, fmt.Sprintf("build version do not exist"))
httputil.ReturnError(r, w, 404, "build version do not exist")
return
}
httputil.ReturnSuccess(r, w, version)
@ -492,7 +492,7 @@ func (t *TenantStruct) GetManyDeployVersion(w http.ResponseWriter, r *http.Reque
}
serviceIDs, ok := data["service_ids"].([]interface{})
if !ok {
httputil.ReturnError(r, w, 400, fmt.Sprintf("service ids must be a array"))
httputil.ReturnError(r, w, 400, "service ids must be a array")
return
}
var list []string
@ -501,7 +501,7 @@ func (t *TenantStruct) GetManyDeployVersion(w http.ResponseWriter, r *http.Reque
}
services, err := db.GetManager().TenantServiceDao().GetServiceByIDs(list)
if err != nil {
httputil.ReturnError(r, w, 500, fmt.Sprintf(err.Error()))
httputil.ReturnError(r, w, 500, err.Error())
return
}
var versionList []*dbmodel.VersionInfo
@ -656,7 +656,6 @@ func (t *TenantStruct) RollBack(w http.ResponseWriter, r *http.Request) {
re := handler.GetOperationHandler().RollBack(rollbackRequest)
httputil.ReturnSuccess(r, w, re)
return
}
type limitMemory struct {

View File

@ -50,7 +50,10 @@ func init() {
}
//CheckCodeSpecification 检查语言规范
func CheckCodeSpecification(buildPath string, lang Lang) Specification {
func CheckCodeSpecification(buildPath string, lang Lang, serverType string) Specification {
if serverType == "oss" && lang == JavaJar {
return common()
}
if check, ok := specification[lang]; ok {
return check(buildPath)
}

View File

@ -300,7 +300,7 @@ func (d *SourceCodeParse) Parse() ParseErrorList {
return d.errors
}
//check code Specification
spec := code.CheckCodeSpecification(buildPath, lang)
spec := code.CheckCodeSpecification(buildPath, lang, csi.ServerType)
if spec.Advice != nil {
for k, v := range spec.Advice {
d.errappend(ErrorAndSolve(NegligibleError, k, v))

View File

@ -74,7 +74,7 @@ func TestSourceCode(t *testing.T) {
func TestOSSCheck(t *testing.T) {
sc := sources.CodeSourceInfo{
ServerType: "oss",
RepositoryURL: "http://8081.gr021644.64q1jlfb.17f4cc.grapps.cn/artifactory/dev/java-war-demo-master.tar.gz",
RepositoryURL: "http://8081.gr021644.64q1jlfb.17f4cc.grapps.cn/artifactory/dev/java-war-demo-master.tar",
User: "demo",
Password: "gr123465!",
}