when encode node device to node hami.io/node-dcu-register annotation, not contain dcu index information. hami scheduler can`t get index information
func EncodeNodeDevices(dlist []*api.DeviceInfo) string {
tmp := ""
for _, val := range dlist {
tmp += val.Id + "," + strconv.FormatInt(int64(val.Count), 10) + "," + strconv.Itoa(int(val.Devmem)) + "," + strconv.Itoa(int(val.Devcore)) + "," + val.Type + "," + strconv.Itoa(val.Numa) + "," + strconv.FormatBool(val.Health) + OneContainerMultiDeviceSplitSymbol
}
klog.Infof("Encoded node Devices: %s", tmp)
return tmp
}
func DecodeNodeDevices(str string) ([]*DeviceInfo, error) {
if !strings.Contains(str, OneContainerMultiDeviceSplitSymbol) {
return []*DeviceInfo{}, errors.New("node annotations not decode successfully")
}
tmp := strings.Split(str, OneContainerMultiDeviceSplitSymbol)
var retval []*DeviceInfo
for _, val := range tmp {
if strings.Contains(val, ",") {
items := strings.Split(val, ",")
if len(items) == 7 || len(items) == 9 {
count, _ := strconv.ParseInt(items[1], 10, 32)
devmem, _ := strconv.ParseInt(items[2], 10, 32)
devcore, _ := strconv.ParseInt(items[3], 10, 32)
health, _ := strconv.ParseBool(items[6])
numa, _ := strconv.Atoi(items[5])
mode := "hami-core"
index := 0
if len(items) == 9 {
index, _ = strconv.Atoi(items[7])
mode = items[8]
}
i := DeviceInfo{
ID: items[0],
Count: int32(count),
Devmem: int32(devmem),
Devcore: int32(devcore),
Type: items[4],
Numa: numa,
Health: health,
Mode: mode,
Index: uint(index),
}
retval = append(retval, &i)
} else {
return []*DeviceInfo{}, errors.New("node annotations not decode successfully")
}
}
}
return retval, nil
}
when encode node device to node hami.io/node-dcu-register annotation, not contain dcu index information. hami scheduler can`t get index information