Skip to content

Commit

Permalink
fix "Failed to enable container runtime: sudo systemctl restart cri-d…
Browse files Browse the repository at this point in the history
…ocker"
  • Loading branch information
prezha committed Jan 6, 2024
1 parent 79e4bb8 commit 7ea9a0d
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,36 @@ func (r *Docker) Enable(disOthers bool, cgroupDriver string, inUserNamespace boo
return err
}

// restart cri-docker
// avoid error: "Exiting due to RUNTIME_ENABLE: Failed to enable container runtime: sudo systemctl restart cri-docker: exit status 1"
// => journalctl: "cri-docker.socket: Socket service cri-docker.service already active, refusing."
if r.CRIService != "" {
if err := r.Init.Enable("cri-docker.socket"); err != nil {
return err
socket := "cri-docker.socket"
service := "cri-docker.service"
// allow "native" socket activation:
// prevent active socket to reactivate service, that we're going to stop next - 'systemctl status cri-docker.socket': "Triggers: cri-docker.service"
// intentionally continue on any error
if r.Init.Active(socket) {
_ = r.Init.Stop(socket)
}
if err := r.Init.Unmask(r.CRIService); err != nil {
return err
if r.Init.Active(service) {
_ = r.Init.Stop(service)
}
if err := r.Init.Enable(r.CRIService); err != nil {

if err := r.Init.Unmask(socket); err != nil {
return err
}
if err := r.Init.Restart(r.CRIService); err != nil {
if err := r.Init.Enable(socket); err != nil {
return err
}
if err := r.Init.Restart("cri-docker"); err != nil {
if err := r.Init.Restart(socket); err != nil {
return err
}

// try to restart service if stopped, intentionally continue on any error
if !r.Init.Active(service) {
_ = r.Init.Restart(service)
}
}

return nil
Expand Down

0 comments on commit 7ea9a0d

Please sign in to comment.