From 2d27ceadefea9d89981ec53b59dc1f0391eb0863 Mon Sep 17 00:00:00 2001 From: Mofei Zhang Date: Wed, 5 Feb 2020 11:02:25 +0800 Subject: [PATCH] Enhancement: validate master address config on object node start Signed-off-by: Mofei Zhang --- objectnode/server.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/objectnode/server.go b/objectnode/server.go index 77f607ed7c..013ca5d4f5 100644 --- a/objectnode/server.go +++ b/objectnode/server.go @@ -125,10 +125,9 @@ func (o *ObjectNode) loadConfig(cfg *config.Config) (err error) { // parse master config enableHTTPS := cfg.GetBool(configEnableHTTPS) - masterCfgs := cfg.GetSlice(proto.MasterAddr) - masters := make([]string, len(masterCfgs)) - for i, masterCfg := range masterCfgs { - masters[i] = masterCfg.(string) + masters := cfg.GetStringSlice(proto.MasterAddr) + if len(masters) == 0 { + return config.NewIllegalConfigError(proto.MasterAddr) } log.LogInfof("loadConfig: setup config: %v(%v)", configMasters, masters)