fix(scheduler): check capacity of disk_schedtag_predicate (#15336)

* only check free_capacity when not migrating or non schared storage

* only check actual_free_capacity when storage is local
This commit is contained in:
Zexi Li
2022-11-10 11:42:38 +08:00
committed by GitHub
parent 7df7b672ab
commit af0dcee9e3
@@ -150,13 +150,18 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core.
if u.GetHypervisorDriver().DoScheduleStorageFilter() {
// free capacity check
if storage.FreeCapacity < int64(d.SizeMb) {
return &FailReason{
Reason: fmt.Sprintf("Storage %s free capacity %d < %d(request)", storage.Name, storage.FreeCapacity, d.SizeMb),
Type: StorageCapacity,
isMigrate := len(u.SchedData().HostId) > 0
if !isMigrate || !utils.IsInStringArray(storage.StorageType, computeapi.SHARED_STORAGE) {
if storage.FreeCapacity < int64(d.SizeMb) {
return &FailReason{
Reason: fmt.Sprintf("Storage %s free capacity %d < %d(request)", storage.Name, storage.FreeCapacity, d.SizeMb),
Type: StorageCapacity,
}
}
}
if storage.ActualFreeCapacity < int64(d.SizeMb) {
// only check ActualFreeCapacity when storage_type is local
if storage.StorageType == computeapi.STORAGE_LOCAL && storage.ActualFreeCapacity < int64(d.SizeMb) {
return &FailReason{
Reason: fmt.Sprintf("Storage %s actual free capacity %d < %d(request)", storage.Name, storage.ActualFreeCapacity, d.SizeMb),
Type: StorageCapacity,