From d16e35c7b9a84b15bf565946be2d50a0fa2b1148 Mon Sep 17 00:00:00 2001 From: Saurav Agarwalla Date: Wed, 26 Feb 2025 10:40:18 -0500 Subject: [PATCH] fix: don't mark pods with 'karpenter.sh/do-not-disrupt=true' as reschedulable --- pkg/utils/pod/scheduling.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/utils/pod/scheduling.go b/pkg/utils/pod/scheduling.go index 2b10a2523c..d05b57862f 100644 --- a/pkg/utils/pod/scheduling.go +++ b/pkg/utils/pod/scheduling.go @@ -39,13 +39,15 @@ func IsActive(pod *corev1.Pod) bool { // - Is an active pod (isn't terminal or actively terminating) OR Is owned by a StatefulSet and Is Terminating // - Isn't owned by a DaemonSet // - Isn't a mirror pod (https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/) +// - Does not have the "karpenter.sh/do-not-disrupt=true" annotation (https://karpenter.sh/docs/concepts/disruption/#pod-level-controls) func IsReschedulable(pod *corev1.Pod) bool { // StatefulSet pods can be handled differently here because we know that StatefulSet pods MUST // get deleted before new pods are re-created. This means that we can model terminating pods for StatefulSets // differently for higher availability by considering terminating pods for scheduling return (IsActive(pod) || (IsOwnedByStatefulSet(pod) && IsTerminating(pod))) && !IsOwnedByDaemonSet(pod) && - !IsOwnedByNode(pod) + !IsOwnedByNode(pod) && + !HasDoNotDisrupt(pod) } // IsEvictable checks if a pod is evictable by Karpenter by ensuring that the pod: