1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 22:31:55 +00:00
This commit is contained in:
Newnius 2020-06-25 11:28:07 +08:00
parent e094fda5c4
commit 3032da0baf
2 changed files with 4 additions and 5 deletions

View File

@ -93,7 +93,7 @@ type MsgJobReq struct {
} }
type MsgJobReqPredict struct { type MsgJobReqPredict struct {
Code int `json:"code"` Code int `json:"code"`
Error string `json:"error"` Error string `json:"error"`
Labels string `json:"labels"` Labels map[string]float64 `json:"labels"`
} }

View File

@ -470,8 +470,7 @@ func (optimizer *Optimizer) PredictReq(job Job, role string) MsgJobReq {
var msg MsgJobReqPredict var msg MsgJobReqPredict
err = json.Unmarshal([]byte(string(body)), &msg) err = json.Unmarshal([]byte(string(body)), &msg)
if err == nil && msg.Code == 0 { if err == nil && msg.Code == 0 {
var tmp map[string]float64 tmp := msg.Labels
err = json.Unmarshal([]byte(msg.Labels), &tmp)
if v, ok := tmp["cpu"]; ok { if v, ok := tmp["cpu"]; ok {
req.CPU = int(math.Ceil(v / 100)) req.CPU = int(math.Ceil(v / 100))
} }