Skip to content

Commit

Permalink
TAS: Cleanup flavor assigner check (kubernetes-sigs#3391)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimowo authored and kannon92 committed Nov 19, 2024
1 parent 7ffae67 commit 05548fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/scheduler/flavorassigner/flavorassigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/scheduler/flavorassigner/tas_flavorassigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 05548fc

Please sign in to comment.