Commit 3e4fd7b4 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Respect --data-dir path for crictl.yaml

Related to rancher/rke2#474 Note that anyone who customizes the data-dir path will have to set CRI_CONFIG_FILE to the correct path when using the wrapped binaries (crictl, etc). This is better than dropping files in the incorrect location. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent f50e3140
......@@ -21,7 +21,6 @@ import (
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/agent"
daemonconfig "github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/datadir"
"github.com/rancher/k3s/pkg/nodeconfig"
"github.com/rancher/k3s/pkg/rootless"
"github.com/rancher/k3s/pkg/version"
......@@ -58,9 +57,9 @@ func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *daemonconfig.Node) error {
}
}
agentConfDir := datadir.DefaultDataDir + "/agent/etc"
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
if _, err := os.Stat(agentConfDir); os.IsNotExist(err) {
if err := os.MkdirAll(agentConfDir, 0755); err != nil {
if err := os.MkdirAll(agentConfDir, 0700); err != nil {
return err
}
}
......@@ -141,12 +140,12 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
}
}
cfg.DataDir = filepath.Join(cfg.DataDir, "agent")
if err := os.MkdirAll(cfg.DataDir, 0700); err != nil {
agentDir := filepath.Join(cfg.DataDir, "agent")
if err := os.MkdirAll(agentDir, 0700); err != nil {
return err
}
proxy, err := proxy.NewAPIProxy(!cfg.DisableLoadBalancer, cfg.DataDir, cfg.ServerURL)
proxy, err := proxy.NewAPIProxy(!cfg.DisableLoadBalancer, agentDir, cfg.ServerURL)
if err != nil {
return err
}
......
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