diff --git a/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes.go b/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes.go index be44a8708481..58459da50f17 100644 --- a/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes.go +++ b/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes.go @@ -53,7 +53,7 @@ func currentlyDrainedPods(context *context.AutoscalingContext) []*apiv1.Pod { for _, podInfo := range nodeInfo.Pods { // Filter out pods that has deletion timestamp set if podInfo.Pod.DeletionTimestamp != nil { - klog.Infof("Pod %v has deletion timestamp set, skipping", podInfo.Pod.Name) + klog.Infof("Pod %v has deletion timestamp set, skipping injection to unschedulable pods list", podInfo.Pod.Name) continue } pods = append(pods, podInfo.Pod) diff --git a/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes_test.go b/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes_test.go index ac94966d5d33..0aebcbd4d671 100644 --- a/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes_test.go +++ b/cluster-autoscaler/core/podlistprocessor/currently_drained_nodes_test.go @@ -77,7 +77,7 @@ func TestCurrentlyDrainedNodesPodListProcessor(t *testing.T) { }, pods: []*apiv1.Pod{ BuildScheduledTestPod("p1", 100, 1, "n"), - BuildTestPodWithDeletionTimestamp("p2", 200, 1, "n", time.Now()), + BuildTestPod("p2", 200, 1, WithNodeName("n"), WithDeletionTimestamp(time.Now())), }, wantPods: []*apiv1.Pod{ BuildTestPod("p1", 100, 1), diff --git a/cluster-autoscaler/utils/test/test_utils.go b/cluster-autoscaler/utils/test/test_utils.go index 2a71befe4823..de868d1ef9c9 100644 --- a/cluster-autoscaler/utils/test/test_utils.go +++ b/cluster-autoscaler/utils/test/test_utils.go @@ -150,6 +150,13 @@ func WithMaxSkew(maxSkew int32, topologySpreadingKey string) func(*apiv1.Pod) { } } +// WithDeletionTimestamp sets deletion timestamp to the pod. +func WithDeletionTimestamp(deletionTimestamp time.Time) func(*apiv1.Pod) { + return func(pod *apiv1.Pod) { + pod.DeletionTimestamp = &metav1.Time{Time: deletionTimestamp} + } +} + // BuildTestPodWithEphemeralStorage creates a pod with cpu, memory and ephemeral storage resources. func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod { startTime := metav1.Unix(0, 0) @@ -195,13 +202,6 @@ func BuildScheduledTestPod(name string, cpu, memory int64, nodeName string) *api return p } -// BuildTestPodWithDeletionTimestamp builds a test pod with deletion timestamp set -func BuildTestPodWithDeletionTimestamp(name string, cpu, memory int64, nodeName string, deletionTimestamp time.Time) *apiv1.Pod { - p := BuildScheduledTestPod(name, cpu, memory, nodeName) - p.DeletionTimestamp = &metav1.Time{Time: deletionTimestamp} - return p -} - // SetStaticPodSpec sets pod spec to make it a static pod func SetStaticPodSpec(pod *apiv1.Pod) *apiv1.Pod { pod.Annotations[kube_types.ConfigSourceAnnotationKey] = kube_types.FileSource