Skip to content

Commit 8217888

Browse files
committed
Omit fake pod evictions
1 parent 2814dca commit 8217888

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cluster-autoscaler/core/scaledown/actuation/drain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
kube_errors "k8s.io/apimachinery/pkg/api/errors"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/autoscaler/cluster-autoscaler/metrics"
30+
"k8s.io/autoscaler/cluster-autoscaler/simulator/fake"
3031
"k8s.io/autoscaler/cluster-autoscaler/simulator/framework"
3132
"k8s.io/klog/v2"
3233
kubelet_config "k8s.io/kubernetes/pkg/kubelet/apis/config"
@@ -276,6 +277,8 @@ func podsToEvict(nodeInfo *framework.NodeInfo, evictDsByDefault bool) (dsPods, n
276277
for _, podInfo := range nodeInfo.Pods() {
277278
if pod_util.IsMirrorPod(podInfo.Pod) {
278279
continue
280+
} else if fake.IsFake(podInfo.Pod) {
281+
continue
279282
} else if pod_util.IsDaemonSetPod(podInfo.Pod) {
280283
dsPods = append(dsPods, podInfo.Pod)
281284
} else {

cluster-autoscaler/core/scaledown/actuation/drain_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"k8s.io/autoscaler/cluster-autoscaler/core/utils"
4141
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot"
4242
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot/testsnapshot"
43+
simulator_fake "k8s.io/autoscaler/cluster-autoscaler/simulator/fake"
4344
"k8s.io/autoscaler/cluster-autoscaler/simulator/framework"
4445
"k8s.io/autoscaler/cluster-autoscaler/utils/daemonset"
4546
kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes"
@@ -683,6 +684,11 @@ func TestPodsToEvict(t *testing.T) {
683684
wantDsPods: []*apiv1.Pod{},
684685
wantNonDsPods: []*apiv1.Pod{},
685686
},
687+
"fake pods are never returned": {
688+
pods: []*apiv1.Pod{fakePod("pod-1"), fakePod("pod-2")},
689+
wantDsPods: []*apiv1.Pod{},
690+
wantNonDsPods: []*apiv1.Pod{},
691+
},
686692
"non-DS pods are correctly returned": {
687693
pods: []*apiv1.Pod{regularPod("pod-1"), regularPod("pod-2")},
688694
wantDsPods: []*apiv1.Pod{},
@@ -766,6 +772,10 @@ func mirrorPod(name string) *apiv1.Pod {
766772
}
767773
}
768774

775+
func fakePod(name string) *apiv1.Pod {
776+
return simulator_fake.WithFakePodAnnotation(regularPod(name))
777+
}
778+
769779
func dsPod(name string, evictable bool) *apiv1.Pod {
770780
pod := &apiv1.Pod{
771781
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)