Change:
kubernetes pre-submit unit tests for pass some times and fails some times causing the flakiness. Here is one such failure https://k8s- Passing: Failing: cc
Yep, I'm checking with this
Sorry for introducing a flakiness. Sent out the fix in .
/assign
Dup of . /close

Discussion:
assert.NoError(t, err) fakePodGetter := m.containerGC.podGetter.(*fakePodGetter) <del> makeGCSandbox := func(pod *v1.Pod, attempt uint32, state runtimeapi.PodSandboxState, withPodGetter bool) sandboxTemplate { </del> <ins> makeGCSandbox := func(pod *v1.Pod, attempt uint32, state runtimeapi.PodSandboxState, withPodGetter bool, createdAt int64) sandboxTemplate { </ins> if withPodGetter { // initialize the pod getter fakePodGetter.pods[pod.UID] = pod } return sandboxTemplate{ <del> pod:     pod, state:   state, attempt: attempt, </del> <ins> pod:       pod, state:     state, attempt:   attempt, createdAt: createdAt, </ins> } }

{ description: "notready sandboxes without containers for deleted pods should be garbage collected.", sandboxes: []sandboxTemplate{ <del> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false), </del> <ins> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false, 0), </ins> }, containers: []containerTemplate{}, remain:     []int{},

{ description: "ready sandboxes without containers for deleted pods should not be garbage collected.", sandboxes: []sandboxTemplate{ <del> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_READY, false), </del> <ins> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_READY, false, 0), </ins> }, containers: []containerTemplate{}, remain:     []int{0},

{ description: "sandboxes for existing pods should not be garbage collected.", sandboxes: []sandboxTemplate{ <del> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_READY, true), makeGCSandbox(pods[1], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true), </del> <ins> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_READY, true, 0), makeGCSandbox(pods[1], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true, 0), </ins> }, containers: []containerTemplate{}, remain:     []int{0, 1},

{ description: "sandbox with containers should not be garbage collected.", sandboxes: []sandboxTemplate{ <del> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false), </del> <ins> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false, 0), </ins> }, containers: []containerTemplate{ {pod: pods[0], container: &pods[0].Spec.Containers[0], state: runtimeapi.ContainerState_CONTAINER_EXITED},

description: "multiple sandboxes should be handled properly.", sandboxes: []sandboxTemplate{ // running sandbox. <del> makeGCSandbox(pods[0], 1, runtimeapi.PodSandboxState_SANDBOX_READY, true), </del> <ins> makeGCSandbox(pods[0], 1, runtimeapi.PodSandboxState_SANDBOX_READY, true, 1), </ins> // exited sandbox without containers. <del> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false), </del> <ins> makeGCSandbox(pods[0], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true, 0), </ins> // exited sandbox with containers. <del> makeGCSandbox(pods[1], 1, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true), </del> <ins> makeGCSandbox(pods[1], 1, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true, 1), </ins> // exited sandbox without containers. <del> makeGCSandbox(pods[1], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false), </del> <ins> makeGCSandbox(pods[1], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, true, 0), </ins> // exited sandbox without containers for deleted pods. <del> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false), </del> <ins> makeGCSandbox(pods[2], 0, runtimeapi.PodSandboxState_SANDBOX_NOTREADY, false, 0), </ins> }, containers: []containerTemplate{ {pod: pods[1], container: &pods[1].Spec.Containers[0], sandboxAttempt: 1, state: runtimeapi.ContainerState_CONTAINER_EXITED},