Skip to content

Commit

Permalink
[FIX] fix cpu unit error bug
Browse files Browse the repository at this point in the history
  • Loading branch information
barnettZQG committed Jan 28, 2019
1 parent 8cfbf30 commit f75512f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/handler/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (t *TenantAction) GetTenantsResources(tr *api_model.TenantResources) (map[s
"service_running_num": tr.RunningAppNum,
"service_total_num": serviceTenantCount[tenantID],
"cpu": tr.CpuRequest,
"memory": tr.MemoryRequest / 1024 / 1024,
"memory": tr.MemoryRequest,
"disk": 0,
}
}
Expand Down
20 changes: 10 additions & 10 deletions worker/appm/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,23 +704,23 @@ func (a *appRuntimeStore) GetTenantResource(tenantID string) *v1.TenantResource
cpurequest := container.Resources.Requests.Cpu()
memoryrequest := container.Resources.Requests.Memory()
if cpulimit != nil {
if cpulimit, ok := cpulimit.AsInt64(); ok {
resource.CPULimit += cpulimit
}
resource.CPULimit += cpulimit.MilliValue()
}
if memorylimit != nil {
if memorylimit, ok := memorylimit.AsInt64(); ok {
resource.MemoryLimit += memorylimit
if ml, ok := memorylimit.AsInt64(); ok {
resource.MemoryLimit += ml
} else {
resource.MemoryLimit += memorylimit.Value()
}
}
if cpurequest != nil {
if cpurequest, ok := cpurequest.AsInt64(); ok {
resource.CPURequest += cpurequest
}
resource.CPURequest += cpurequest.MilliValue()
}
if memoryrequest != nil {
if memoryrequest, ok := memoryrequest.AsInt64(); ok {
resource.MemoryRequest += memoryrequest
if mr, ok := memoryrequest.AsInt64(); ok {
resource.MemoryRequest += mr
} else {
resource.MemoryRequest += memoryrequest.Value()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions worker/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (r *RuntimeServer) GetTenantResource(ctx context.Context, re *pb.TenantRequ
return &tr, nil
}
tr.RunningAppNum = int64(len(r.store.GetTenantRunningApp(re.TenantId)))
tr.CpuLimit = res.CPULimit
tr.CpuRequest = res.CPURequest
tr.CpuLimit = res.CPULimit * 1000
tr.CpuRequest = res.CPURequest * 1000
tr.MemoryLimit = res.MemoryLimit / 1024 / 1024
tr.MemoryRequest = res.MemoryRequest / 1024 / 1024
return &tr, nil
Expand Down

0 comments on commit f75512f

Please sign in to comment.