From 76692bbe5fc2648d54ba358e35ed7cd21433b927 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 3 Oct 2018 13:59:33 -0700 Subject: [PATCH] executor: clean up static config files Signed-off-by: Tonis Tiigi --- executor/containerdexecutor/executor.go | 5 +++++ executor/runcexecutor/executor.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/executor/containerdexecutor/executor.go b/executor/containerdexecutor/executor.go index 398bec74..ed6553aa 100644 --- a/executor/containerdexecutor/executor.go +++ b/executor/containerdexecutor/executor.go @@ -3,6 +3,7 @@ package containerdexecutor import ( "context" "io" + "os" "path/filepath" "strings" "syscall" @@ -33,6 +34,10 @@ type containerdExecutor struct { // New creates a new executor backed by connection to containerd API func New(client *containerd.Client, root, cgroup string, networkProviders map[pb.NetMode]network.Provider) executor.Executor { + // clean up old hosts/resolv.conf file. ignore errors + os.RemoveAll(filepath.Join(root, "hosts")) + os.RemoveAll(filepath.Join(root, "resolv.conf")) + return containerdExecutor{ client: client, root: root, diff --git a/executor/runcexecutor/executor.go b/executor/runcexecutor/executor.go index dca82ffd..8080f571 100644 --- a/executor/runcexecutor/executor.go +++ b/executor/runcexecutor/executor.go @@ -85,6 +85,10 @@ func New(opt Opt, networkProviders map[pb.NetMode]network.Provider) (executor.Ex return nil, err } + // clean up old hosts/resolv.conf file. ignore errors + os.RemoveAll(filepath.Join(root, "hosts")) + os.RemoveAll(filepath.Join(root, "resolv.conf")) + runtime := &runc.Runc{ Command: cmd, Log: filepath.Join(root, "runc-log.json"),