Skip to content

Commit 30b952c

Browse files
committed
add missing pod disruption reasons to isPodDead
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.
1 parent 97c411b commit 30b952c

File tree

1 file changed

+11
-19
lines changed
  • pkg/controller/registry/reconciler

1 file changed

+11
-19
lines changed

pkg/controller/registry/reconciler/grpc.go

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -542,36 +542,28 @@ func imageChanged(logger *logrus.Entry, updatePod *corev1.Pod, servingPods []*co
542542
}
543543

544544
func isPodDead(pod *corev1.Pod) bool {
545-
for _, check := range []func(*corev1.Pod) bool{
546-
isPodDeletedByTaintManager,
547-
isPodTerminatedByKubelet,
545+
for _, agentReason := range []string{
546+
"PreemptionByScheduler",
547+
"DeletionByTaintManager",
548+
"EvictionByEvictionAPI",
549+
"DeletionByPodGC",
550+
"TerminationByKubelet",
548551
} {
549-
if check(pod) {
552+
if isPodDeletedByExternalAgent(pod, agentReason) {
550553
return true
551554
}
552555
}
553556
return false
554557
}
555558

556-
func isPodDeletedByTaintManager(pod *corev1.Pod) bool {
559+
// isPodDeletedByExternalAgent checks if the pod has one of the conditions
560+
// listed in https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-conditions
561+
func isPodDeletedByExternalAgent(pod *corev1.Pod, agentReason string) bool {
557562
if pod.DeletionTimestamp == nil {
558563
return false
559564
}
560565
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-
}
573-
for _, condition := range pod.Status.Conditions {
574-
if condition.Type == corev1.DisruptionTarget && condition.Reason == "TerminationByKubelet" && condition.Status == corev1.ConditionTrue {
566+
if condition.Type == corev1.DisruptionTarget && condition.Reason == agentReason && condition.Status == corev1.ConditionTrue {
575567
return true
576568
}
577569
}

0 commit comments

Comments
 (0)