Merge pull request #120514 from fengxsong/patch-1

fix: check if initsystem service exists
This commit is contained in:
Kubernetes Prow Robot 2023-09-15 14:08:23 -07:00 committed by GitHub
commit 0241da314e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,7 +125,7 @@ func (sysd SystemdInitSystem) ServiceExists(service string) bool {
args := []string{"status", service}
outBytes, _ := exec.Command("systemctl", args...).Output()
output := string(outBytes)
return !strings.Contains(output, "Loaded: not-found")
return !strings.Contains(output, "Loaded: not-found") && !strings.Contains(output, "could not be found")
}
// ServiceIsEnabled ensures the service is enabled to start on each boot.