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-24 23:58:38 +08:00
parent 9609c500dc
commit e094fda5c4
2 changed files with 5 additions and 4 deletions

View File

@ -95,5 +95,5 @@ 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 map[string]float64 `json:"labels"` Labels string `json:"labels"`
} }

View File

@ -470,7 +470,8 @@ 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 {
tmp := msg.Labels var tmp map[string]float64
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))
} }