Skip to content

Commit 59bfe7f

Browse files
authored
add missing pod disruption reasons to isPodDead (#3519)
isPodDead had checks for TerminationByKubelet and DeletionByTaintManager. It was missing checks for PreemptionByScheduler EvictionByEvictionAPI DeletionByPodGC ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-conditions This PR adds those reasons. Signed-off-by: Anik Bhattacharjee <[email protected]>
1 parent 95cef87 commit 59bfe7f

File tree

1 file changed

+4
-29
lines changed
  • pkg/controller/registry/reconciler

1 file changed

+4
-29
lines changed

Diff for: pkg/controller/registry/reconciler/grpc.go

+4-29
Original file line numberDiff line numberDiff line change
@@ -541,37 +541,12 @@ func imageChanged(logger *logrus.Entry, updatePod *corev1.Pod, servingPods []*co
541541
return false
542542
}
543543

544+
// isPodDead checks if the pod has the DisruptionTarget condition set to true,
545+
// which indicates that the Pod is about to be deleted due to a disruption.
546+
// ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-conditions
544547
func isPodDead(pod *corev1.Pod) bool {
545-
for _, check := range []func(*corev1.Pod) bool{
546-
isPodDeletedByTaintManager,
547-
isPodTerminatedByKubelet,
548-
} {
549-
if check(pod) {
550-
return true
551-
}
552-
}
553-
return false
554-
}
555-
556-
func isPodDeletedByTaintManager(pod *corev1.Pod) bool {
557-
if pod.DeletionTimestamp == nil {
558-
return false
559-
}
560-
for _, condition := range pod.Status.Conditions {
561-
if condition.Type == corev1.DisruptionTarget && condition.Reason == "DeletionByTaintManager" && condition.Status == corev1.ConditionTrue {
562-
return true
563-
}
564-
}
565-
return false
566-
}
567-
568-
// This reason is set when the Pod was evicted due to resource pressure on the Node
569-
func isPodTerminatedByKubelet(pod *corev1.Pod) bool {
570-
if pod.DeletionTimestamp == nil {
571-
return false
572-
}
573548
for _, condition := range pod.Status.Conditions {
574-
if condition.Type == corev1.DisruptionTarget && condition.Reason == "TerminationByKubelet" && condition.Status == corev1.ConditionTrue {
549+
if condition.Type == corev1.DisruptionTarget && condition.Status == corev1.ConditionTrue {
575550
return true
576551
}
577552
}

0 commit comments

Comments
 (0)