mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
reset kuberuntime_container
This commit is contained in:
parent
266d1c886a
commit
3710d6f570
@ -1082,9 +1082,6 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
message := fmt.Sprintf("Init container %s", container.Name)
|
|
||||||
var reason containerKillReason
|
|
||||||
restartContainer := false
|
|
||||||
switch status.State {
|
switch status.State {
|
||||||
case kubecontainer.ContainerStateCreated:
|
case kubecontainer.ContainerStateCreated:
|
||||||
// The main sync loop should have created and started the container
|
// The main sync loop should have created and started the container
|
||||||
@ -1110,9 +1107,13 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
if startup == proberesults.Failure {
|
if startup == proberesults.Failure {
|
||||||
// If the restartable init container failed the startup probe,
|
// If the restartable init container failed the startup probe,
|
||||||
// restart it.
|
// restart it.
|
||||||
message = fmt.Sprintf("%s failed startup probe, will be restarted", message)
|
changes.ContainersToKill[status.ID] = containerToKillInfo{
|
||||||
reason = reasonStartupProbe
|
name: container.Name,
|
||||||
restartContainer = true
|
container: container,
|
||||||
|
message: fmt.Sprintf("Init container %s failed startup probe", container.Name),
|
||||||
|
reason: reasonStartupProbe,
|
||||||
|
}
|
||||||
|
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1126,13 +1127,6 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
changes.InitContainersToStart = append(changes.InitContainersToStart, i+1)
|
changes.InitContainersToStart = append(changes.InitContainersToStart, i+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart running sidecar containers which have had their definition changed.
|
|
||||||
if _, _, changed := containerChanged(container, status); changed {
|
|
||||||
message = fmt.Sprintf("%s definition changed, will be restarted", message)
|
|
||||||
restartContainer = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// A restartable init container does not have to take into account its
|
// A restartable init container does not have to take into account its
|
||||||
// liveness probe when it determines to start the next init container.
|
// liveness probe when it determines to start the next init container.
|
||||||
if container.LivenessProbe != nil {
|
if container.LivenessProbe != nil {
|
||||||
@ -1144,13 +1138,15 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
if liveness == proberesults.Failure {
|
if liveness == proberesults.Failure {
|
||||||
// If the restartable init container failed the liveness probe,
|
// If the restartable init container failed the liveness probe,
|
||||||
// restart it.
|
// restart it.
|
||||||
message = fmt.Sprintf("%s failed liveness probe, will be restarted", message)
|
changes.ContainersToKill[status.ID] = containerToKillInfo{
|
||||||
reason = reasonLivenessProbe
|
name: container.Name,
|
||||||
restartContainer = true
|
container: container,
|
||||||
break
|
message: fmt.Sprintf("Init container %s failed liveness probe", container.Name),
|
||||||
|
reason: reasonLivenessProbe,
|
||||||
|
}
|
||||||
|
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // init container
|
} else { // init container
|
||||||
// nothing do to but wait for it to finish
|
// nothing do to but wait for it to finish
|
||||||
break
|
break
|
||||||
@ -1184,9 +1180,14 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
default: // kubecontainer.ContainerStatusUnknown or other unknown states
|
default: // kubecontainer.ContainerStatusUnknown or other unknown states
|
||||||
if types.IsRestartableInitContainer(container) {
|
if types.IsRestartableInitContainer(container) {
|
||||||
// If the restartable init container is in unknown state, restart it.
|
// If the restartable init container is in unknown state, restart it.
|
||||||
message = fmt.Sprintf("%s is in %q state, try killing it before restart", message, status.State)
|
changes.ContainersToKill[status.ID] = containerToKillInfo{
|
||||||
reason = reasonUnknown
|
name: container.Name,
|
||||||
restartContainer = true
|
container: container,
|
||||||
|
message: fmt.Sprintf("Init container is in %q state, try killing it before restart",
|
||||||
|
status.State),
|
||||||
|
reason: reasonUnknown,
|
||||||
|
}
|
||||||
|
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
|
||||||
} else { // init container
|
} else { // init container
|
||||||
if !isInitContainerFailed(status) {
|
if !isInitContainerFailed(status) {
|
||||||
klog.V(4).InfoS("This should not happen, init container is in unknown state but not failed", "pod", klog.KObj(pod), "containerStatus", status)
|
klog.V(4).InfoS("This should not happen, init container is in unknown state but not failed", "pod", klog.KObj(pod), "containerStatus", status)
|
||||||
@ -1199,23 +1200,17 @@ func (m *kubeGenericRuntimeManager) computeInitContainerActions(pod *v1.Pod, pod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the init container is in unknown state, restart it.
|
// If the init container is in unknown state, restart it.
|
||||||
message = fmt.Sprintf("%s is in %q state, try killing it before restart", message, status.State)
|
changes.ContainersToKill[status.ID] = containerToKillInfo{
|
||||||
reason = reasonUnknown
|
name: container.Name,
|
||||||
restartContainer = true
|
container: container,
|
||||||
|
message: fmt.Sprintf("Init container is in %q state, try killing it before restart",
|
||||||
|
status.State),
|
||||||
|
reason: reasonUnknown,
|
||||||
|
}
|
||||||
|
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if restartContainer {
|
|
||||||
changes.ContainersToKill[status.ID] = containerToKillInfo{
|
|
||||||
name: container.Name,
|
|
||||||
container: container,
|
|
||||||
message: message,
|
|
||||||
reason: reason,
|
|
||||||
}
|
|
||||||
changes.InitContainersToStart = append(changes.InitContainersToStart, i)
|
|
||||||
klog.V(4).InfoS("Message for Init Container of pod", "containerName", container.Name, "containerStatusID", status.ID, "pod", klog.KObj(pod), "containerMessage", message)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !isPreviouslyInitialized {
|
if !isPreviouslyInitialized {
|
||||||
// the one before this init container has been initialized
|
// the one before this init container has been initialized
|
||||||
isPreviouslyInitialized = true
|
isPreviouslyInitialized = true
|
||||||
|
Loading…
Reference in New Issue
Block a user