Skip to content

Commit 6a2766d

Browse files
authored
Merge pull request #8215 from k8s-infra-cherrypick-robot/cherry-pick-6725-to-cluster-autoscaler-release-1.30
[cluster-autoscaler-release-1.30] filter out pods that have deletion timestamp set in currentlyDrainedPods
2 parents d5e9c9e + 39c3d4f commit 6a2766d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

cluster-autoscaler/core/podlistprocessor/currently_drained_nodes.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ func currentlyDrainedPods(context *context.AutoscalingContext) []*apiv1.Pod {
5151
continue
5252
}
5353
for _, podInfo := range nodeInfo.Pods {
54+
// Filter out pods that has deletion timestamp set
55+
if podInfo.Pod.DeletionTimestamp != nil {
56+
klog.Infof("Pod %v has deletion timestamp set, skipping injection to unschedulable pods list", podInfo.Pod.Name)
57+
continue
58+
}
5459
pods = append(pods, podInfo.Pod)
5560
}
5661
}

cluster-autoscaler/core/podlistprocessor/currently_drained_nodes_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ func TestCurrentlyDrainedNodesPodListProcessor(t *testing.T) {
6969
BuildTestPod("p2", 200, 1),
7070
},
7171
},
72+
{
73+
name: "single node undergoing deletion, pods with deletion timestamp set",
74+
drainedNodes: []string{"n"},
75+
nodes: []*apiv1.Node{
76+
BuildTestNode("n", 1000, 10),
77+
},
78+
pods: []*apiv1.Pod{
79+
BuildScheduledTestPod("p1", 100, 1, "n"),
80+
BuildTestPod("p2", 200, 1, WithNodeName("n"), WithDeletionTimestamp(time.Now())),
81+
},
82+
wantPods: []*apiv1.Pod{
83+
BuildTestPod("p1", 100, 1),
84+
},
85+
},
7286
{
7387
name: "single empty node undergoing deletion",
7488
drainedNodes: []string{"n"},

cluster-autoscaler/utils/test/test_utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ func WithMaxSkew(maxSkew int32, topologySpreadingKey string) func(*apiv1.Pod) {
150150
}
151151
}
152152

153+
// WithDeletionTimestamp sets deletion timestamp to the pod.
154+
func WithDeletionTimestamp(deletionTimestamp time.Time) func(*apiv1.Pod) {
155+
return func(pod *apiv1.Pod) {
156+
pod.DeletionTimestamp = &metav1.Time{Time: deletionTimestamp}
157+
}
158+
}
159+
153160
// BuildTestPodWithEphemeralStorage creates a pod with cpu, memory and ephemeral storage resources.
154161
func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod {
155162
startTime := metav1.Unix(0, 0)

0 commit comments

Comments
 (0)