Skip to content

Commit bfa69c2

Browse files
committed
neonvm-controller: check if deletion timestamp is in the past (#1055)
If we are passed the mark of the deletion timestamp, it means the deletion is stuck, and we should consider the pod to be failed anyway. Possible reasons for this are: 1. Node is down. 2. Pod is stuck pulling the image from the container registry. Signed-off-by: Oleg Vasilev <[email protected]>
1 parent dee47a1 commit bfa69c2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/neonvm/controllers/vm_controller.go

+8
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,14 @@ const (
939939
// This is *similar* to the value of pod.Status.Phase, but we'd like to retain our own abstraction
940940
// to have more control over the semantics.
941941
func runnerStatus(pod *corev1.Pod) runnerStatusKind {
942+
// Add 5 seconds to account for clock skew and k8s lagging behind.
943+
deadline := metav1.NewTime(metav1.Now().Add(-5 * time.Second))
944+
945+
// If the pod is being deleted, we consider it failed. The deletion might be stalled
946+
// because the node is shutting down, or the pod is stuck pulling an image.
947+
if pod.DeletionTimestamp != nil && pod.DeletionTimestamp.Before(&deadline) {
948+
return runnerFailed
949+
}
942950
switch pod.Status.Phase {
943951
case "", corev1.PodPending:
944952
return runnerPending

0 commit comments

Comments
 (0)