Skip to content

Commit a044a4c

Browse files
fix restart
1 parent ff5fb39 commit a044a4c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pkg/minikube/cruntime/docker.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,14 @@ func (r *Docker) Enable(disOthers bool, cgroupDriver string, inUserNamespace boo
197197
return err
198198
}
199199

200-
// try to restart service if stopped, intentionally continue on any error
201-
if !r.Init.Active(service) {
200+
_ = r.Init.Restart(service)
201+
// try to restart service if stopped, restart until it works
202+
for !r.Init.Active(service) {
203+
fmt.Println("stuck")
204+
time.Sleep(5 * time.Second)
202205
_ = r.Init.Restart(service)
206+
time.Sleep(5 * time.Second)
207+
203208
}
204209
}
205210

pkg/minikube/sysinit/systemd.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ func (s *Systemd) Restart(svc string) error {
110110
if err := s.daemonReload(); err != nil {
111111
return err
112112
}
113-
_, err := s.r.RunCmd(exec.Command("sudo", "systemctl", "restart", svc))
113+
// some services declare a realitive small restart-limit in their .service configuration
114+
// so we reset reset-failed counter to override the limit
115+
// and always force restart the service
116+
_, err := s.r.RunCmd(exec.Command("sudo", "systemctl", "reset-failed", svc))
117+
if err != nil {
118+
return err
119+
}
120+
_, err = s.r.RunCmd(exec.Command("sudo", "systemctl", "restart", svc))
114121
return s.appendJournalctlLogsOnFailure(svc, err)
115122
}
116123

0 commit comments

Comments
 (0)