diff --git a/pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux.go b/pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux.go index bfbb841a1fa..1e857528f6a 100644 --- a/pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux.go +++ b/pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux.go @@ -316,6 +316,10 @@ func (m *managerImpl) processShutdownEvent() error { klog.V(1).InfoS("Shutdown manager killing pod with gracePeriod", "pod", klog.KObj(pod), "gracePeriod", gracePeriodOverride) if err := m.killPodFunc(pod, false, &gracePeriodOverride, func(status *v1.PodStatus) { + // set the pod status to failed (unless it was already in a successful terminal phase) + if status.Phase != v1.PodSucceeded { + status.Phase = v1.PodFailed + } status.Message = nodeShutdownMessage status.Reason = nodeShutdownReason }); err != nil { diff --git a/test/e2e_node/node_shutdown_linux_test.go b/test/e2e_node/node_shutdown_linux_test.go index eca0e681513..b7dd727cc5e 100644 --- a/test/e2e_node/node_shutdown_linux_test.go +++ b/test/e2e_node/node_shutdown_linux_test.go @@ -510,5 +510,5 @@ func isPodShutdown(pod *v1.Pod) bool { } } - return pod.Status.Message == podShutdownMessage && pod.Status.Reason == podShutdownReason && hasContainersNotReadyCondition + return pod.Status.Message == podShutdownMessage && pod.Status.Reason == podShutdownReason && hasContainersNotReadyCondition && pod.Status.Phase == v1.PodFailed }