Skip to content

Commit 8e39847

Browse files
authored
catalog-operator: Delete Pods that were evicted (#3459)
This change adds another reason why a Pod could be detected as "dead", namely when it was evicted by the kubelet. This can happen when there is resource pressure on the Node. Then the reason will be "TerminationByKubelet". This addresses the issue described in https://issues.redhat.com/browse/OCPBUGS-45490 Signed-off-by: Simon Krenger <[email protected]>
1 parent 3911cac commit 8e39847

File tree

1 file changed

+14
-0
lines changed
  • pkg/controller/registry/reconciler

1 file changed

+14
-0
lines changed

pkg/controller/registry/reconciler/grpc.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ func imageChanged(logger *logrus.Entry, updatePod *corev1.Pod, servingPods []*co
531531
func isPodDead(pod *corev1.Pod) bool {
532532
for _, check := range []func(*corev1.Pod) bool{
533533
isPodDeletedByTaintManager,
534+
isPodTerminatedByKubelet,
534535
} {
535536
if check(pod) {
536537
return true
@@ -551,6 +552,19 @@ func isPodDeletedByTaintManager(pod *corev1.Pod) bool {
551552
return false
552553
}
553554

555+
// This reason is set when the Pod was evicted due to resource pressure on the Node
556+
func isPodTerminatedByKubelet(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 == "TerminationByKubelet" && condition.Status == corev1.ConditionTrue {
562+
return true
563+
}
564+
}
565+
return false
566+
}
567+
554568
// imageID returns the ImageID of the primary catalog source container or an empty string if the image ID isn't available yet.
555569
// Note: the pod must be running and the container in a ready status to return a valid ImageID.
556570
func imageID(pod *corev1.Pod) string {

0 commit comments

Comments
 (0)