From 6b21af79c20e91f2be30017060068ba210facf63 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Fri, 2 Aug 2019 13:00:50 +0300 Subject: [PATCH] kubeadm: simplified returns --- .../app/util/initsystem/initsystem_unix.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go index 73a133a444133..f3dbb36e99a97 100644 --- a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go +++ b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go @@ -52,30 +52,21 @@ func (openrc OpenRCInitSystem) ServiceRestart(service string) error { func (openrc OpenRCInitSystem) ServiceExists(service string) bool { args := []string{service, "status"} outBytes, _ := exec.Command("rc-service", args...).CombinedOutput() - if strings.Contains(string(outBytes), "does not exist") { - return false - } - return true + return !strings.Contains(string(outBytes), "does not exist") } // ServiceIsEnabled ensures the service is enabled to start on each boot. func (openrc OpenRCInitSystem) ServiceIsEnabled(service string) bool { args := []string{"show", "default"} outBytes, _ := exec.Command("rc-update", args...).Output() - if strings.Contains(string(outBytes), service) { - return true - } - return false + return strings.Contains(string(outBytes), service) } // ServiceIsActive ensures the service is running, or attempting to run. (crash looping in the case of kubelet) func (openrc OpenRCInitSystem) ServiceIsActive(service string) bool { args := []string{service, "status"} outBytes, _ := exec.Command("rc-service", args...).Output() - if strings.Contains(string(outBytes), "stopped") { - return false - } - return true + return !strings.Contains(string(outBytes), "stopped") } // EnableCommand return a string describing how to enable a service