Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pods are not restarted when changing the init container's image #82523

Open
sofat1989 opened this issue Sep 10, 2019 · 2 comments

Comments

@sofat1989
Copy link

commented Sep 10, 2019

From the doc here, https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#pod-restart-reasons

A user updates the Pod specification, causing the init container image to change. Any changes to the init container image restarts the Pod. App container image changes only restart the app container.

I updated the init container image, we didnt get any changes for these pods.
init containers are not re-executed.

From the logic of computePodActions here, it does not calculate the hash change for the init container.

// Check initialization progress.
	initLastStatus, next, done := findNextInitContainerToRun(pod, podStatus)
	if !done {
		if next != nil {
			initFailed := initLastStatus != nil && isInitContainerFailed(initLastStatus)
			if initFailed && !shouldRestartOnFailure(pod) {
				changes.KillPod = true
			} else {
				// Always try to stop containers in unknown state first.
				if initLastStatus != nil && initLastStatus.State == kubecontainer.ContainerStateUnknown {
					changes.ContainersToKill[initLastStatus.ID] = containerToKillInfo{
						name:      next.Name,
						container: next,
						message: fmt.Sprintf("Init container is in %q state, try killing it before restart",
							initLastStatus.State),
					}
				}
				changes.NextInitContainerToStart = next
			}
		}
		// Initialization failed or still in progress. Skip inspecting non-init
		// containers.
		return changes
	}

/sig node

@xiaoanyunfei

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

/assign

@krmayankk

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2019

@sofat1989 did you test this with deployment or statefulset or with a plain pod yaml ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.