From af0dcee9e3981386d7c0ffee6da983d6f1c85656 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 10 Nov 2022 11:42:38 +0800 Subject: [PATCH] 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 --- .../predicates/disk_schedtag_predicate.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go index 4a12c78c32..fe04878afe 100644 --- a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go +++ b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go @@ -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,