diff --git a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go index 7a027d3277..fe91914fa6 100644 --- a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go +++ b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go @@ -148,6 +148,20 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core. } } + // 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: StorageOwnership, + } + } + if 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: StorageOwnership, + } + } + return nil } diff --git a/pkg/scheduler/api/types.go b/pkg/scheduler/api/types.go index d9663c05cd..28c38f6fe5 100644 --- a/pkg/scheduler/api/types.go +++ b/pkg/scheduler/api/types.go @@ -95,8 +95,9 @@ func SchedtagStrategyCheck(strategy string) (err error) { type CandidateStorage struct { *models.SStorage - Schedtags []models.SSchedtag `json:"schedtags"` - FreeCapacity int64 `json:"free_capacity"` + Schedtags []models.SSchedtag `json:"schedtags"` + FreeCapacity int64 `json:"free_capacity"` + ActualFreeCapacity int64 `json:"actual_free_capacity"` } type CandidateNetwork struct { diff --git a/pkg/scheduler/cache/candidate/base.go b/pkg/scheduler/cache/candidate/base.go index f25fa246d1..dd1d22233a 100644 --- a/pkg/scheduler/cache/candidate/base.go +++ b/pkg/scheduler/cache/candidate/base.go @@ -677,9 +677,10 @@ func (b *BaseHostDesc) fillStorages(host *computemodels.SHost) error { for _, s := range host.GetHoststorages() { storage := s.GetStorage() ss = append(ss, &api.CandidateStorage{ - SStorage: storage, - FreeCapacity: storage.GetFreeCapacity(), - Schedtags: storage.GetSchedtags(), + SStorage: storage, + FreeCapacity: storage.GetFreeCapacity(), + ActualFreeCapacity: storage.Capacity - storage.ActualCapacityUsed, + Schedtags: storage.GetSchedtags(), }) } b.Storages = ss diff --git a/pkg/scheduler/cache/candidate/hosts.go b/pkg/scheduler/cache/candidate/hosts.go index 1039697765..2aff4cab78 100644 --- a/pkg/scheduler/cache/candidate/hosts.go +++ b/pkg/scheduler/cache/candidate/hosts.go @@ -328,7 +328,7 @@ func (h *HostDesc) freeStorageSizeOfType(storageType string, useRsvd bool) (int6 for _, storage := range h.Storages { if storage.StorageType == storageType { total += int64(storage.FreeCapacity) - actualTotal += storage.Capacity - storage.ActualCapacityUsed + actualTotal += int64(storage.ActualFreeCapacity) } } if utils.IsLocalStorage(storageType) {