Skip to content

Commit

Permalink
fix the thing where I broke soft affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
bwagner5 committed Nov 24, 2021
1 parent 562d4e8 commit 0c9c03e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/controllers/provisioning/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,17 @@ func (p *Provisioner) Batch(ctx context.Context) (pods []*v1.Pod) {
// between the time it was ingested into the scheduler and the time it is included
// in a provisioner batch.
func (p *Provisioner) FilterProvisionable(ctx context.Context, pods []*v1.Pod) []*v1.Pod {
unscheduled := []*v1.Pod{}
provisionable := []*v1.Pod{}
for _, pod := range pods {
candidate := pod
// the original pod should be returned rather than the newly fetched pod in case the scheduler relaxed constraints
original := pod
candidate := &v1.Pod{}
if err := p.kubeClient.Get(ctx, types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}, candidate); err != nil {
logging.FromContext(ctx).Errorf("Unexpected error retrieving pod \"%s/%s\" while checking if it is provisionable", pod.Namespace, pod.Name)
}
if !isProvisionable(candidate) {
continue
if candidate.Spec.NodeName == "" {
provisionable = append(provisionable, original)
}
unscheduled = append(unscheduled, candidate)
}
return unscheduled
return provisionable
}

0 comments on commit 0c9c03e

Please sign in to comment.