From 58dfe186d8c143858c4f3ce445e0700d23292123 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Sun, 26 May 2019 14:40:03 -0700 Subject: [PATCH] Call getKubeletSandboxes first in containerGC#evictSandboxes --- pkg/kubelet/kuberuntime/kuberuntime_gc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_gc.go b/pkg/kubelet/kuberuntime/kuberuntime_gc.go index f22430a7fa3..b139dba9272 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_gc.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_gc.go @@ -277,17 +277,17 @@ func (cgc *containerGC) evictSandboxes(evictTerminatedPods bool) error { return err } + sandboxes, err := cgc.manager.getKubeletSandboxes(true) + if err != nil { + return err + } + // collect all the PodSandboxId of container sandboxIDs := sets.NewString() for _, container := range containers { sandboxIDs.Insert(container.PodSandboxId) } - sandboxes, err := cgc.manager.getKubeletSandboxes(true) - if err != nil { - return err - } - sandboxesByPod := make(sandboxesByPodUID) for _, sandbox := range sandboxes { podUID := types.UID(sandbox.Metadata.Uid)