diff --git a/pkg/kubelet/kuberuntime/kuberuntime_manager_test.go b/pkg/kubelet/kuberuntime/kuberuntime_manager_test.go index b8157b8c940..85a06794eeb 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_manager_test.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_manager_test.go @@ -750,6 +750,7 @@ func makeBasePodAndStatus() (*v1.Pod, *kubecontainer.PodStatus) { Id: "sandboxID", State: runtimeapi.PodSandboxState_SANDBOX_READY, Metadata: &runtimeapi.PodSandboxMetadata{Name: pod.Name, Namespace: pod.Namespace, Uid: "sandboxuid", Attempt: uint32(0)}, + Network: &runtimeapi.PodSandboxNetworkStatus{Ip: "10.0.0.1"}, }, }, ContainerStatuses: []*kubecontainer.ContainerStatus{ @@ -883,7 +884,19 @@ func TestComputePodActions(t *testing.T) { ContainersToKill: getKillMap(basePod, baseStatus, []int{}), }, }, - + "Kill pod and recreate all containers if the PodSandbox does not have an IP": { + mutateStatusFn: func(status *kubecontainer.PodStatus) { + status.SandboxStatuses[0].Network.Ip = "" + }, + actions: podActions{ + KillPod: true, + CreateSandbox: true, + SandboxID: baseStatus.SandboxStatuses[0].Id, + Attempt: uint32(1), + ContainersToStart: []int{0, 1, 2}, + ContainersToKill: getKillMap(basePod, baseStatus, []int{}), + }, + }, "Kill and recreate the container if the container's spec changed": { mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyAlways