Skip to content

Commit

Permalink
Fixed a bug where hostname topology caused extra nodes to be launched
Browse files Browse the repository at this point in the history
  • Loading branch information
ellistarn committed Nov 27, 2021
1 parent 5d5798b commit 709562c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/controllers/provisioning/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/provisioning/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 709562c

Please sign in to comment.