Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: simplified returns #80894

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions cmd/kubeadm/app/util/initsystem/initsystem_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down