From 8af62533229f82afcf60a95cd93a00c30a90eb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cdonghong=E2=80=9D?= Date: Thu, 21 Jul 2022 16:59:41 +0800 Subject: [PATCH] fix if restart pod sanbox container, sanbox /etc/resolv.conf will be restore to host /etc/resolv.conf. --- cri/v1alpha2/cri.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cri/v1alpha2/cri.go b/cri/v1alpha2/cri.go index a1d06687d..18aaf76de 100644 --- a/cri/v1alpha2/cri.go +++ b/cri/v1alpha2/cri.go @@ -427,6 +427,13 @@ func (c *CriManager) StartPodSandbox(ctx context.Context, r *runtime.StartPodSan } } + // Setup sandbox file /etc/resolv.conf again to ensure resolv.conf is right + sandboxRootDir := path.Join(c.SandboxBaseDir, sandbox.ID) + err = setupSandboxFiles(sandboxRootDir, sandboxMeta.Config) + if err != nil { + return nil, fmt.Errorf("failed to setup sandbox files: %v", err) + } + metrics.PodSuccessActionsCounter.WithLabelValues(label).Inc() return &runtime.StartPodSandboxResponse{}, nil