mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
Properly handle init containers in convertToAPIContainerStatuses
This commit is contained in:
@@ -3669,6 +3669,14 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *api.Pod, podStatus *kubeco
|
||||
|
||||
// Handle the containers failed to be started, which should be in Waiting state.
|
||||
for _, container := range containers {
|
||||
if isInitContainer {
|
||||
// If the init container is terminated with exit code 0, it won't be restarted.
|
||||
// TODO(random-liu): Handle this in a cleaner way.
|
||||
s := podStatus.FindContainerStatusByName(container.Name)
|
||||
if s != nil && s.State == kubecontainer.ContainerStateExited && s.ExitCode == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// If a container should be restarted in next syncpod, it is *Waiting*.
|
||||
if !kubecontainer.ShouldContainerBeRestarted(&container, pod, podStatus) {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user