Skip to content

Commit

Permalink
Fix empty node name in watched nodes (#60)
Browse files Browse the repository at this point in the history
Before, if we had a pod without a nodeName (which
happens when a pod is pending), it was added to
watchedNodes as empty string. It could also be
used in the intersection with disruption to calculate
the budgets. Now, we ignore the pod if its node is
missing.
  • Loading branch information
geobeau authored Apr 5, 2024
1 parent 2624aa1 commit 08e16e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
Expect(k8sClient.Create(ctx, &pod1)).Should(Succeed())
pod2 := newPod("podadb2", ADBNamespace, "node2", podLabels)
Expect(k8sClient.Create(ctx, &pod2)).Should(Succeed())
// Add a pod without node, i.e. pending
pod3 := newPod("podadb3", ADBNamespace, "", podLabels)
Expect(k8sClient.Create(ctx, &pod3)).Should(Succeed())
pvc3 := newPVC("pvc3", ADBNamespace, "node3-pv-local", podLabels)
Expect(k8sClient.Create(ctx, &pvc3)).Should(Succeed())

Expand Down
4 changes: 3 additions & 1 deletion pkg/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func (r *Resolver) GetNodesFromNamespacedPodSelector(ctx context.Context, podSel
}

for _, pod := range pods.Items {
nodeNames.Insert(pod.Spec.NodeName)
if pod.Spec.NodeName != "" {
nodeNames.Insert(pod.Spec.NodeName)
}
}
return nodeSet, nil
}
Expand Down

0 comments on commit 08e16e7

Please sign in to comment.