From bf30c48eeaae4e11089adbdb6bd3ea215eb92a3e Mon Sep 17 00:00:00 2001 From: rainzm Date: Mon, 16 Nov 2020 20:46:31 +0800 Subject: [PATCH] feat(scheduler): support filtering storage via medium --- .../algorithm/predicates/disk_schedtag_predicate.go | 9 ++++++++- pkg/scheduler/algorithm/predicates/error.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go index 51ee5a0aee..dc19b2183c 100644 --- a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go +++ b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go @@ -120,7 +120,14 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(u *core.Unit, c core.Candidat } } } - + if len(d.Medium) != 0 { + if storage.MediumType != d.Medium { + return &FailReason{ + fmt.Sprintf("Storage %s medium %s != %s", storage.Name, storage.MediumType, d.Medium), + StorageMedium, + } + } + } storageTypes := p.GetHypervisorDriver().GetStorageTypes() if len(storageTypes) != 0 && !utils.IsInStringArray(storage.StorageType, storageTypes) { return &FailReason{ diff --git a/pkg/scheduler/algorithm/predicates/error.go b/pkg/scheduler/algorithm/predicates/error.go index ae5147cb42..3c65c03dd3 100644 --- a/pkg/scheduler/algorithm/predicates/error.go +++ b/pkg/scheduler/algorithm/predicates/error.go @@ -126,4 +126,5 @@ const ( StorageMatch = "storage_match" StorageType = "storage_type" StorageOwnership = "storage_ownership" + StorageMedium = "storage_medium" )