mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #51644 from sjenning/init-container-status-fix
Automatic merge from submit-queue (batch tested with PRs 51239, 51644, 52076) do not update init containers status if terminated fixes #29972 #41580 This fixes an issue where, if a completed init container is removed while the pod or subsequent init containers are still running, the status for that init container will be reset to `Waiting` with `PodInitializing`. This can manifest in a number of ways. If the init container is removed why the main pod containers are running, the status will be reset with no functional problem but the status will be reported incorrectly in `kubectl get pod` for example If the init container is removed why a subsequent init container is running, the init container will be **re-executed** leading to all manner of badness. @derekwaynecarr @bparees
This commit is contained in:
commit
ae6b329368
@ -1412,10 +1412,17 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
||||
Image: container.Image,
|
||||
State: defaultWaitingState,
|
||||
}
|
||||
// Apply some values from the old statuses as the default values.
|
||||
if oldStatus, found := oldStatuses[container.Name]; found {
|
||||
status.RestartCount = oldStatus.RestartCount
|
||||
status.LastTerminationState = oldStatus.LastTerminationState
|
||||
oldStatus, found := oldStatuses[container.Name]
|
||||
if found {
|
||||
if isInitContainer && oldStatus.State.Terminated != nil {
|
||||
// Do not update status on terminated init containers as
|
||||
// they be removed at any time.
|
||||
status = &oldStatus
|
||||
} else {
|
||||
// Apply some values from the old statuses as the default values.
|
||||
status.RestartCount = oldStatus.RestartCount
|
||||
status.LastTerminationState = oldStatus.LastTerminationState
|
||||
}
|
||||
}
|
||||
statuses[container.Name] = status
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user