Skip to content

Commit

Permalink
Merge pull request #11667 from ilya-zuyev/fix_docker_stop_log
Browse files Browse the repository at this point in the history
Do not return an error from Systemd.ForceStop(svc) if svc is already stopped
  • Loading branch information
ilya-zuyev authored Jun 22, 2021
2 parents cb4123a + 654a963 commit d4fe773
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/minikube/sysinit/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package sysinit

import (
"errors"
"fmt"
"os/exec"
"strings"

"k8s.io/minikube/pkg/minikube/assets"
)
Expand Down Expand Up @@ -123,7 +125,14 @@ func (s *Systemd) Stop(svc string) error {

// ForceStop terminates a service with prejudice
func (s *Systemd) ForceStop(svc string) error {
_, err := s.r.RunCmd(exec.Command("sudo", "systemctl", "stop", "-f", svc))
rr, err := s.r.RunCmd(exec.Command("sudo", "systemctl", "stop", "-f", svc))
if err == nil {
return nil
}
if strings.Contains(rr.Output(), fmt.Sprintf("Unit %s not loaded", svc)) {
// already stopped
return nil
}
return err
}

Expand Down

0 comments on commit d4fe773

Please sign in to comment.