UPSTREAM: 59767: kubelet: check for illegal phase transition
@@ -1379,6 +1379,15 @@ func (kl *Kubelet) generateAPIPodStatus(pod *v1.Pod, podStatus *kubecontainer.Po
spec := &pod.Spec
allStatus := append(append([]v1.ContainerStatus{}, s.ContainerStatuses...), s.InitContainerStatuses...)
s.Phase = GetPhase(spec, allStatus)
+ // Check for illegal phase transition
+ if pod.Status.Phase == v1.PodFailed || pod.Status.Phase == v1.PodSucceeded {
+ // API server shows terminal phase; transitions are not allowed
+ if s.Phase != pod.Status.Phase {
+ glog.Errorf("Pod attempted illegal phase transition from %s to %s: %v", pod.Status.Phase, s.Phase, s)
+ // Force back to phase from the API server
+ s.Phase = pod.Status.Phase
+ }
+ }
kl.probeManager.UpdatePodStatus(pod.UID, s)
s.Conditions = append(s.Conditions, status.GeneratePodInitializedCondition(spec, s.InitContainerStatuses, s.Phase))
s.Conditions = append(s.Conditions, status.GeneratePodReadyCondition(spec, s.ContainerStatuses, s.Phase))
