Skip to content

Commit

Permalink
add missing pod disruption reasons to isPodDead (#3519)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
anik120 authored Feb 25, 2025
1 parent 95cef87 commit 59bfe7f
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions pkg/controller/registry/reconciler/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,37 +541,12 @@ func imageChanged(logger *logrus.Entry, updatePod *corev1.Pod, servingPods []*co
return false
}

// isPodDead checks if the pod has the DisruptionTarget condition set to true,
// which indicates that the Pod is about to be deleted due to a disruption.
// ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-conditions
func isPodDead(pod *corev1.Pod) bool {
for _, check := range []func(*corev1.Pod) bool{
isPodDeletedByTaintManager,
isPodTerminatedByKubelet,
} {
if check(pod) {
return true
}
}
return false
}

func isPodDeletedByTaintManager(pod *corev1.Pod) bool {
if pod.DeletionTimestamp == nil {
return false
}
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.DisruptionTarget && condition.Reason == "DeletionByTaintManager" && condition.Status == corev1.ConditionTrue {
return true
}
}
return false
}

// This reason is set when the Pod was evicted due to resource pressure on the Node
func isPodTerminatedByKubelet(pod *corev1.Pod) bool {
if pod.DeletionTimestamp == nil {
return false
}
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.DisruptionTarget && condition.Reason == "TerminationByKubelet" && condition.Status == corev1.ConditionTrue {
if condition.Type == corev1.DisruptionTarget && condition.Status == corev1.ConditionTrue {
return true
}
}
Expand Down

0 comments on commit 59bfe7f

Please sign in to comment.