From 03faa1e7848e1ec2fbee0d43692b04ce1bbc9936 Mon Sep 17 00:00:00 2001 From: Michal Wozniak Date: Thu, 31 Oct 2024 10:38:25 +0100 Subject: [PATCH] TAS: Cleanup flavor assigner check --- pkg/scheduler/flavorassigner/flavorassigner.go | 13 +++---------- pkg/scheduler/flavorassigner/tas_flavorassigner.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pkg/scheduler/flavorassigner/flavorassigner.go b/pkg/scheduler/flavorassigner/flavorassigner.go index b5cfa99e96..2b5acc886a 100644 --- a/pkg/scheduler/flavorassigner/flavorassigner.go +++ b/pkg/scheduler/flavorassigner/flavorassigner.go @@ -443,16 +443,9 @@ func (a *FlavorAssigner) findFlavorForPodSetResource( continue } if features.Enabled(features.TopologyAwareScheduling) { - // For PodSets which require TAS skip resource flavors which don't support it - if ps.TopologyRequest != nil && flavor.Spec.TopologyName == nil { - log.Error(nil, "Flavor does not support TopologyAwareScheduling", "Flavor", fName) - status.append(fmt.Sprintf("flavor %s does not support TopologyAwareScheduling", fName)) - continue - } - // For PodSets which don't use TAS skip resource flavors which are only for TAS - if ps.TopologyRequest == nil && flavor.Spec.TopologyName != nil { - log.Error(nil, "Flavor supports only TopologyAwareScheduling", "Flavor", fName) - status.append(fmt.Sprintf("flavor %s supports only TopologyAwareScheduling", fName)) + if message := checkPodSetAndFlavorMatchForTAS(ps, flavor); message != nil { + log.Error(nil, *message) + status.append(*message) continue } } diff --git a/pkg/scheduler/flavorassigner/tas_flavorassigner.go b/pkg/scheduler/flavorassigner/tas_flavorassigner.go index a26ebe635f..c6d7f5107d 100644 --- a/pkg/scheduler/flavorassigner/tas_flavorassigner.go +++ b/pkg/scheduler/flavorassigner/tas_flavorassigner.go @@ -21,6 +21,7 @@ import ( "fmt" "github.com/go-logr/logr" + "k8s.io/utils/ptr" kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" "sigs.k8s.io/kueue/pkg/cache" @@ -90,3 +91,15 @@ func onlyFlavor(ra ResourceAssignment) (*kueue.ResourceFlavorReference, error) { } return nil, errors.New("no flavor assigned") } + +func checkPodSetAndFlavorMatchForTAS(ps *kueue.PodSet, flavor *kueue.ResourceFlavor) *string { + // For PodSets which require TAS skip resource flavors which don't support it + if ps.TopologyRequest != nil && flavor.Spec.TopologyName == nil { + return ptr.To(fmt.Sprintf("Flavor %q does not support TopologyAwareScheduling", flavor.Name)) + } + // For PodSets which don't use TAS skip resource flavors which are only for TAS + if ps.TopologyRequest == nil && flavor.Spec.TopologyName != nil { + return ptr.To(fmt.Sprintf("Flavor %q supports only TopologyAwareScheduling", flavor.Name)) + } + return nil +}