mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user