From f82b8cdc95d2b986b453e5f0d919ef89c0754c21 Mon Sep 17 00:00:00 2001 From: Abdullah Gharaibeh Date: Fri, 25 Feb 2022 17:30:52 -0500 Subject: [PATCH] clarifications --- pkg/capacity/capacity.go | 7 +++++-- pkg/scheduler/scheduler.go | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/capacity/capacity.go b/pkg/capacity/capacity.go index c0971b2025..a47ffddc89 100644 --- a/pkg/capacity/capacity.go +++ b/pkg/capacity/capacity.go @@ -78,7 +78,10 @@ type Capacity struct { RequestableResources map[corev1.ResourceName][]FlavorInfo UsedResources Resources Workloads map[string]*workload.Info - LabelKeys map[corev1.ResourceName]sets.String + // The set of key labels from all flavors of a resource. + // Those keys define the affinity terms of a workload + // that can be matched against the flavors. + LabelKeys map[corev1.ResourceName]sets.String } // FlavorInfo holds processed flavor type. @@ -370,7 +373,7 @@ func resourcesByName(in []kueue.Resource) map[corev1.ResourceName][]FlavorInfo { Taints: append([]corev1.Taint(nil), f.Taints...), } if len(f.Labels) != 0 { - fInfo.Labels = map[string]string{} + fInfo.Labels = make(map[string]string, len(f.Labels)) for k, v := range f.Labels { fInfo.Labels[k] = v } diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index 4e2a4785b8..fe0bdcd039 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -242,10 +242,9 @@ func (s *Scheduler) assign(ctx context.Context, e *entry) error { // given that wUsed is the usage of flavors by previous podsets. // If it finds a flavor, also returns any borrowing required. func findFlavorForResource(name corev1.ResourceName, val int64, wUsed map[string]int64, cap *capacity.Capacity, spec *corev1.PodSpec) (string, int64) { + // We will only check against the flavors' labels for the resource. + selector := flavorSelector(spec, cap.LabelKeys[name]) for _, flavor := range cap.RequestableResources[name] { - // We will only check against the flavors labels. - selector := flavorSelector(spec, cap.LabelKeys[name]) - _, untolerated := corev1helpers.FindMatchingUntoleratedTaint(flavor.Taints, spec.Tolerations, func(t *corev1.Taint) bool { return t.Effect == corev1.TaintEffectNoSchedule || t.Effect == corev1.TaintEffectNoExecute })