mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #96572 from sjenning/dont-rerun-init
kubelet: do not rerun init containers if any main containers have status
This commit is contained in:
commit
125530629a
@ -744,6 +744,18 @@ func findNextInitContainerToRun(pod *v1.Pod, podStatus *kubecontainer.PodStatus)
|
||||
return nil, nil, true
|
||||
}
|
||||
|
||||
// If any of the main containers have status and are Running, then all init containers must
|
||||
// have been executed at some point in the past. However, they could have been removed
|
||||
// from the container runtime now, and if we proceed, it would appear as if they
|
||||
// never ran and will re-execute improperly.
|
||||
for i := range pod.Spec.Containers {
|
||||
container := &pod.Spec.Containers[i]
|
||||
status := podStatus.FindContainerStatusByName(container.Name)
|
||||
if status != nil && status.State == kubecontainer.ContainerStateRunning {
|
||||
return nil, nil, true
|
||||
}
|
||||
}
|
||||
|
||||
// If there are failed containers, return the status of the last failed one.
|
||||
for i := len(pod.Spec.InitContainers) - 1; i >= 0; i-- {
|
||||
container := &pod.Spec.InitContainers[i]
|
||||
|
Loading…
Reference in New Issue
Block a user