Skip to content

Commit

Permalink
Resepect --data-dir path for crictl.yaml
Browse files Browse the repository at this point in the history
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).

Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Nov 4, 2020
1 parent 9559011 commit 282abae
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 282abae

Please sign in to comment.