diff --git a/pkg/controllers/provisioning/controller.go b/pkg/controllers/provisioning/controller.go index 30d3daea21ed..376f091661f6 100644 --- a/pkg/controllers/provisioning/controller.go +++ b/pkg/controllers/provisioning/controller.go @@ -98,7 +98,8 @@ func (c *Controller) Apply(ctx context.Context, provisioner *v1alpha5.Provisione provisioner.Spec.Labels = functional.UnionStringMaps(provisioner.Spec.Labels, map[string]string{v1alpha5.ProvisionerNameLabelKey: provisioner.Name}) provisioner.Spec.Requirements = provisioner.Spec.Requirements. With(requirements(instanceTypes)). - With(v1alpha5.LabelRequirements(provisioner.Spec.Labels)) + With(v1alpha5.LabelRequirements(provisioner.Spec.Labels)). + Consolidate() if !c.hasChanged(ctx, provisioner) { // If the provisionerSpecs haven't changed, we don't need to stop and drain the current Provisioner. return nil diff --git a/pkg/controllers/provisioning/scheduling/scheduler.go b/pkg/controllers/provisioning/scheduling/scheduler.go index c25b300201ac..e360e4c27918 100644 --- a/pkg/controllers/provisioning/scheduling/scheduler.go +++ b/pkg/controllers/provisioning/scheduling/scheduler.go @@ -69,17 +69,17 @@ func NewScheduler(kubeClient client.Client, cloudProvider cloudprovider.CloudPro } func (s *Scheduler) Solve(ctx context.Context, provisioner *v1alpha5.Provisioner, pods []*v1.Pod) (schedules []*Schedule, err error) { - defer metrics.Measure(schedulingDuration.WithLabelValues(injection.GetNamespacedName(ctx).Name))() + constraints := provisioner.Spec.Constraints.DeepCopy() // Inject temporarily adds specific NodeSelectors to pods, which are then // used by scheduling logic. This isn't strictly necessary, but is a useful // trick to avoid passing topology decisions through the scheduling code. It // lets us to treat TopologySpreadConstraints as just-in-time NodeSelectors. - if err := s.Topology.Inject(ctx, &provisioner.Spec.Constraints, pods); err != nil { + if err := s.Topology.Inject(ctx, constraints, pods); err != nil { return nil, fmt.Errorf("injecting topology, %w", err) } // Separate pods into schedules of isomorphic scheduling constraints. - schedules, err = s.getSchedules(ctx, &provisioner.Spec.Constraints, pods) + schedules, err = s.getSchedules(ctx, constraints, pods) if err != nil { return nil, fmt.Errorf("getting schedules, %w", err) }