mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #80894 from bart0sh/PR0077-kubeadm-simplified-returns
kubeadm: simplified returns
This commit is contained in:
commit
40178ccf7f
@ -52,30 +52,21 @@ func (openrc OpenRCInitSystem) ServiceRestart(service string) error {
|
|||||||
func (openrc OpenRCInitSystem) ServiceExists(service string) bool {
|
func (openrc OpenRCInitSystem) ServiceExists(service string) bool {
|
||||||
args := []string{service, "status"}
|
args := []string{service, "status"}
|
||||||
outBytes, _ := exec.Command("rc-service", args...).CombinedOutput()
|
outBytes, _ := exec.Command("rc-service", args...).CombinedOutput()
|
||||||
if strings.Contains(string(outBytes), "does not exist") {
|
return !strings.Contains(string(outBytes), "does not exist")
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceIsEnabled ensures the service is enabled to start on each boot.
|
// ServiceIsEnabled ensures the service is enabled to start on each boot.
|
||||||
func (openrc OpenRCInitSystem) ServiceIsEnabled(service string) bool {
|
func (openrc OpenRCInitSystem) ServiceIsEnabled(service string) bool {
|
||||||
args := []string{"show", "default"}
|
args := []string{"show", "default"}
|
||||||
outBytes, _ := exec.Command("rc-update", args...).Output()
|
outBytes, _ := exec.Command("rc-update", args...).Output()
|
||||||
if strings.Contains(string(outBytes), service) {
|
return strings.Contains(string(outBytes), service)
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceIsActive ensures the service is running, or attempting to run. (crash looping in the case of kubelet)
|
// ServiceIsActive ensures the service is running, or attempting to run. (crash looping in the case of kubelet)
|
||||||
func (openrc OpenRCInitSystem) ServiceIsActive(service string) bool {
|
func (openrc OpenRCInitSystem) ServiceIsActive(service string) bool {
|
||||||
args := []string{service, "status"}
|
args := []string{service, "status"}
|
||||||
outBytes, _ := exec.Command("rc-service", args...).Output()
|
outBytes, _ := exec.Command("rc-service", args...).Output()
|
||||||
if strings.Contains(string(outBytes), "stopped") {
|
return !strings.Contains(string(outBytes), "stopped")
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableCommand return a string describing how to enable a service
|
// EnableCommand return a string describing how to enable a service
|
||||||
|
Loading…
Reference in New Issue
Block a user