From 01179963cec3cecc417e1329ce28a112b0995f4c Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Thu, 11 Apr 2019 17:05:57 +0100 Subject: [PATCH 1/2] Don't assume master if 0 master binaries specified --- cmd/common.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/common.go b/cmd/common.go index 9e29edec..2d6463c5 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -202,9 +202,15 @@ func isMaster() bool { _ = loadConfig(check.MASTER) glog.V(2).Info("Checking if the current node is running master components") masterConf := viper.Sub(string(check.MASTER)) - if _, err := getBinaries(masterConf); err != nil { + components, err := getBinaries(masterConf) + + if err != nil { glog.V(2).Info(err) return false } + if len(components) == 0 { + glog.V(2).Info("No master binaries specified") + return false + } return true } From 248942e2faf8364890bef041496eb98b4eec4a88 Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Thu, 11 Apr 2019 18:28:08 +0100 Subject: [PATCH 2/2] No need to load config just to check if components are running. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also allows for there to be no master.yaml file, for environments where such a thing doesn’t need to exist --- cmd/common.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/common.go b/cmd/common.go index 2d6463c5..ed6e9b58 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -199,7 +199,6 @@ func loadConfig(nodetype check.NodeType) string { // isMaster verify if master components are running on the node. func isMaster() bool { - _ = loadConfig(check.MASTER) glog.V(2).Info("Checking if the current node is running master components") masterConf := viper.Sub(string(check.MASTER)) components, err := getBinaries(masterConf)