Merge pull request #15194 from zexi/automated-cherry-pick-of-#15192-upstream-master

Automated cherry pick of #15192: fix(scheduler): check free capacity of each storage
This commit is contained in:
Zexi Li
2022-10-14 13:33:14 +08:00
committed by GitHub
4 changed files with 22 additions and 6 deletions
@@ -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
}
+3 -2
View File
@@ -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 {
+4 -3
View File
@@ -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
+1 -1
View File
@@ -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) {