From a69f56e1375956096a79ff0e345b7d860ede78b6 Mon Sep 17 00:00:00 2001 From: fengxsong Date: Fri, 8 Sep 2023 11:15:07 +0800 Subject: [PATCH] fix: check if initsystem service exists when detecting whether a service exists, if it does not, the output result will be like "Unit noneexists.service could not be found." on ubuntu:20.04 --- cmd/kubeadm/app/util/initsystem/initsystem_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go index 40acb69fed3..04c21772127 100644 --- a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go +++ b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go @@ -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.