Merge pull request #11667 from ilya-zuyev/fix_docker_stop_log

Do not return an error from Systemd.ForceStop(svc) if svc is already stopped
pull/11720/head
ilya-zuyev 2021-06-22 10:10:20 -07:00 committed by GitHub
commit d4fe77356c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -19,7 +19,9 @@ package sysinit
import (
"errors"
"fmt"
"os/exec"
"strings"
"k8s.io/minikube/pkg/minikube/assets"
)
@ -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
}