|
|
|
@ -64,59 +64,30 @@ func cleanIDs(list string) []string {
|
|
|
|
|
return ids
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func verifyConf(confPath ...string) {
|
|
|
|
|
var missing string
|
|
|
|
|
|
|
|
|
|
for _, c := range confPath {
|
|
|
|
|
if _, err := os.Stat(c); err != nil && os.IsNotExist(err) {
|
|
|
|
|
continueWithError(err, "")
|
|
|
|
|
missing += c + ", "
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(missing) > 0 {
|
|
|
|
|
missing = strings.Trim(missing, ", ")
|
|
|
|
|
printlnWarn(fmt.Sprintf("Missing kubernetes config files: %s", missing))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func verifyBin(binPath ...string) {
|
|
|
|
|
var binSlice []string
|
|
|
|
|
var bin string
|
|
|
|
|
var missing string
|
|
|
|
|
var notRunning string
|
|
|
|
|
|
|
|
|
|
// Construct proc name for ps(1)
|
|
|
|
|
for _, b := range binPath {
|
|
|
|
|
_, err := exec.LookPath(b)
|
|
|
|
|
bin = bin + "," + b
|
|
|
|
|
binSlice = append(binSlice, b)
|
|
|
|
|
if err != nil {
|
|
|
|
|
missing += b + ", "
|
|
|
|
|
continueWithError(err, "")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bin = strings.Trim(bin, ",")
|
|
|
|
|
|
|
|
|
|
cmd := exec.Command("ps", "-C", bin, "-o", "cmd", "--no-headers")
|
|
|
|
|
// ps execs out to the ps command; it's separated into a function so we can write tests
|
|
|
|
|
func ps(proc string) string {
|
|
|
|
|
cmd := exec.Command("ps", "-C", proc, "-o", "cmd", "--no-headers")
|
|
|
|
|
out, err := cmd.Output()
|
|
|
|
|
if err != nil {
|
|
|
|
|
continueWithError(fmt.Errorf("%s: %s", cmd.Args, err), "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, b := range binSlice {
|
|
|
|
|
matched := strings.Contains(string(out), b)
|
|
|
|
|
|
|
|
|
|
if !matched {
|
|
|
|
|
notRunning += b + ", "
|
|
|
|
|
}
|
|
|
|
|
return string(out)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(notRunning) > 0 {
|
|
|
|
|
notRunning = strings.Trim(notRunning, ", ")
|
|
|
|
|
printlnWarn(fmt.Sprintf("Kubernetes binaries not running: %s", notRunning))
|
|
|
|
|
}
|
|
|
|
|
// verifyBin checks that the binary specified is running
|
|
|
|
|
func verifyBin(bin string, psFunc func(string) string) bool {
|
|
|
|
|
|
|
|
|
|
// Strip any quotes
|
|
|
|
|
bin = strings.Trim(bin, "'\"")
|
|
|
|
|
|
|
|
|
|
// bin could consist of more than one word
|
|
|
|
|
// We'll search for running processes with the first word, and then check the whole
|
|
|
|
|
// proc as supplied is included in the results
|
|
|
|
|
proc := strings.Fields(bin)[0]
|
|
|
|
|
out := psFunc(proc)
|
|
|
|
|
|
|
|
|
|
return strings.Contains(out, bin)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func verifyKubeVersion(major string, minor string) {
|
|
|
|
@ -133,8 +104,10 @@ func verifyKubeVersion(major string, minor string) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
s := fmt.Sprintf("Kubernetes version check skipped with error %v", err)
|
|
|
|
|
continueWithError(err, sprintlnWarn(s))
|
|
|
|
|
if len(out) == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg := checkVersion("Client", string(out), major, minor)
|
|
|
|
|
if msg != "" {
|
|
|
|
|