fix(region): validate is reserve all cpus

This commit is contained in:
wanyaoqi
2023-09-20 19:41:04 +08:00
parent 53d4b0c1b7
commit 1f4079a863
+6 -1
View File
@@ -4274,9 +4274,14 @@ func (hh *SHost) PerformReserveCpus(
return nil, err
}
if !sets.NewInt(allCores...).HasAll(cs.ToSlice()...) {
hSets := sets.NewInt(allCores...)
cSlice := cs.ToSlice()
if !hSets.HasAll(cSlice...) {
return nil, httperrors.NewInputParameterError("Host cores not contains input %v", input.Cpus)
}
if hSets.Len() == len(cSlice) {
return nil, httperrors.NewInputParameterError("Can't reserve host all cpus")
}
if input.Mems != "" {
mems, err := cpuset.Parse(input.Mems)