Commit 1d4f995e authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Move auto-generated resolv.conf out of /tmp to prevent accidental cleanup

parent a935a420
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"time" "time"
"github.com/k3s-io/k3s/pkg/agent/proxy" "github.com/k3s-io/k3s/pkg/agent/proxy"
agentutil "github.com/k3s-io/k3s/pkg/agent/util"
"github.com/k3s-io/k3s/pkg/cli/cmds" "github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/clientaccess" "github.com/k3s-io/k3s/pkg/clientaccess"
"github.com/k3s-io/k3s/pkg/containerd" "github.com/k3s-io/k3s/pkg/containerd"
...@@ -306,12 +307,13 @@ func locateOrGenerateResolvConf(envInfo *cmds.Agent) string { ...@@ -306,12 +307,13 @@ func locateOrGenerateResolvConf(envInfo *cmds.Agent) string {
} }
} }
tmpConf := filepath.Join(os.TempDir(), version.Program+"-resolv.conf") resolvConf := filepath.Join(envInfo.DataDir, "agent", "etc", "resolv.conf")
if err := ioutil.WriteFile(tmpConf, []byte("nameserver 8.8.8.8\n"), 0444); err != nil { if err := agentutil.WriteFile(resolvConf, "nameserver 8.8.8.8\n"); err != nil {
logrus.Errorf("Failed to write %s: %v", tmpConf, err) logrus.Errorf("Failed to write %s: %v", resolvConf, err)
return "" return ""
} }
return tmpConf logrus.Warnf("Host resolv.conf includes loopback or multicast nameservers - kubelet will use autogenerated resolv.conf with nameserver 8.8.8.8")
return resolvConf
} }
func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.Node, error) { func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.Node, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment