Add startupProbe result handling to kuberuntime
This commit is contained in:
@@ -41,6 +41,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
|
||||
proberesults "k8s.io/kubernetes/pkg/kubelet/prober/results"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -732,6 +733,7 @@ func TestComputePodActions(t *testing.T) {
|
||||
mutatePodFn func(*v1.Pod)
|
||||
mutateStatusFn func(*kubecontainer.PodStatus)
|
||||
actions podActions
|
||||
resetStatusFn func(*kubecontainer.PodStatus)
|
||||
}{
|
||||
"everying is good; do nothing": {
|
||||
actions: noAction,
|
||||
@@ -850,8 +852,38 @@ func TestComputePodActions(t *testing.T) {
|
||||
ContainersToKill: getKillMap(basePod, baseStatus, []int{1}),
|
||||
ContainersToStart: []int{1},
|
||||
},
|
||||
// TODO: Add a test case for containers which failed the liveness
|
||||
// check. Will need to fake the livessness check result.
|
||||
},
|
||||
"Kill and recreate the container if the liveness check has failed": {
|
||||
mutatePodFn: func(pod *v1.Pod) {
|
||||
pod.Spec.RestartPolicy = v1.RestartPolicyAlways
|
||||
},
|
||||
mutateStatusFn: func(status *kubecontainer.PodStatus) {
|
||||
m.livenessManager.Set(status.ContainerStatuses[1].ID, proberesults.Failure, basePod)
|
||||
},
|
||||
actions: podActions{
|
||||
SandboxID: baseStatus.SandboxStatuses[0].Id,
|
||||
ContainersToKill: getKillMap(basePod, baseStatus, []int{1}),
|
||||
ContainersToStart: []int{1},
|
||||
},
|
||||
resetStatusFn: func(status *kubecontainer.PodStatus) {
|
||||
m.livenessManager.Remove(status.ContainerStatuses[1].ID)
|
||||
},
|
||||
},
|
||||
"Kill and recreate the container if the startup check has failed": {
|
||||
mutatePodFn: func(pod *v1.Pod) {
|
||||
pod.Spec.RestartPolicy = v1.RestartPolicyAlways
|
||||
},
|
||||
mutateStatusFn: func(status *kubecontainer.PodStatus) {
|
||||
m.startupManager.Set(status.ContainerStatuses[1].ID, proberesults.Failure, basePod)
|
||||
},
|
||||
actions: podActions{
|
||||
SandboxID: baseStatus.SandboxStatuses[0].Id,
|
||||
ContainersToKill: getKillMap(basePod, baseStatus, []int{1}),
|
||||
ContainersToStart: []int{1},
|
||||
},
|
||||
resetStatusFn: func(status *kubecontainer.PodStatus) {
|
||||
m.startupManager.Remove(status.ContainerStatuses[1].ID)
|
||||
},
|
||||
},
|
||||
"Verify we do not create a pod sandbox if no ready sandbox for pod with RestartPolicy=Never and all containers exited": {
|
||||
mutatePodFn: func(pod *v1.Pod) {
|
||||
@@ -917,6 +949,9 @@ func TestComputePodActions(t *testing.T) {
|
||||
}
|
||||
actions := m.computePodActions(pod, status)
|
||||
verifyActions(t, &test.actions, &actions, desc)
|
||||
if test.resetStatusFn != nil {
|
||||
test.resetStatusFn(status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user