Skip to content

Commit fb1728c

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 7948e19 commit fb1728c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/neonvm/controllers/vm_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,12 @@ const (
935935
// This is *similar* to the value of pod.Status.Phase, but we'd like to retain our own abstraction
936936
// to have more control over the semantics.
937937
func runnerStatus(pod *corev1.Pod) runnerStatusKind {
938+
// Add 5 seconds to account for clock skew and k8s lagging behind.
939+
deadline := metav1.NewTime(metav1.Now().Add(-5 * time.Second))
940+
941+
if pod.DeletionTimestamp != nil && pod.DeletionTimestamp.Before(lo.ToPtr(deadline)) {
942+
return runnerFailed
943+
}
938944
switch pod.Status.Phase {
939945
case "", corev1.PodPending:
940946
return runnerPending

0 commit comments

Comments
 (0)