add restart on definition change

This commit is contained in:
Daniel Shebib 2024-10-18 15:35:06 -05:00
parent 3710d6f570
commit 43d527ad68
2 changed files with 13 additions and 1 deletions

View File

@ -1127,6 +1127,18 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
changes.InitContainersToStart = append(changes.InitContainersToStart, i+1)
}
// Restart running sidecar containers which have had their definition changed.
if _, _, changed := containerChanged(container, status); changed {
changes.ContainersToKill[status.ID] = containerToKillInfo{
name: container.Name,
container: container,
message: fmt.Sprintf("Init container %s definition changed", container.Name),
reason: "",
}
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
break
}
// A restartable init container does not have to take into account its
// liveness probe when it determines to start the next init container.
if container.LivenessProbe != nil {

View File

@ -3717,7 +3717,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
err = e2epod.WaitForPodCondition(ctx, f.ClientSet, pod.Namespace, pod.Name, "init container attempted to run with updated image",
time.Duration(30)*time.Second, func(pod *v1.Pod) (bool, error) {
containerStatus := pod.Status.InitContainerStatuses[1]
return containerStatus.Image == updatedImage, nil
return containerStatus.Image == updatedImage && containerStatus.RestartCount > 1, nil
})
framework.ExpectNoError(err)