Skip to content

Commit

Permalink
Merge pull request #15784 from afbjorklund/cri-dockerd-path
Browse files Browse the repository at this point in the history
Look for cri-dockerd instead of hardcoding
  • Loading branch information
medyagh authored Feb 17, 2023
2 parents 3719f06 + 90bc8a9 commit d8b4a2d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,14 @@ const (
CNICacheDir = "/var/lib/cni/cache"
)

func getCriDockerdPath(cr CommandRunner) string {
rr, err := cr.RunCmd(exec.Command("which", "cri-dockerd"))
if err != nil {
return "/usr/bin/cri-dockerd"
}
return strings.TrimSuffix(rr.Stdout.String(), "\n")
}

func dockerConfigureNetworkPlugin(cr CommandRunner, networkPlugin string) error {
// $ cri-dockerd --version
// cri-dockerd 0.2.6 (d8accf7)
Expand All @@ -702,17 +710,19 @@ func dockerConfigureNetworkPlugin(cr CommandRunner, networkPlugin string) error
networkPlugin = "cni"
}
opts := struct {
ExecPath string
NetworkPlugin string
ExtraArguments string
}{
ExecPath: getCriDockerdPath(cr),
NetworkPlugin: networkPlugin,
ExtraArguments: args,
}

const CRIDockerServiceConfFile = "/etc/systemd/system/cri-docker.service.d/10-cni.conf"
var CRIDockerServiceConfTemplate = template.Must(template.New("criDockerServiceConfTemplate").Parse(`[Service]
ExecStart=
ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd:// --network-plugin={{.NetworkPlugin}}{{.ExtraArguments}}`))
ExecStart={{.ExecPath}} --container-runtime-endpoint fd:// --network-plugin={{.NetworkPlugin}}{{.ExtraArguments}}`))

b := bytes.Buffer{}
if err := CRIDockerServiceConfTemplate.Execute(&b, opts); err != nil {
Expand Down

0 comments on commit d8b4a2d

Please sign in to comment.