From 03485632ea6b99ca833745b3ed1ad1b65def7cdd Mon Sep 17 00:00:00 2001 From: Hussein Galal Date: Wed, 17 Nov 2021 23:22:18 +0200 Subject: [PATCH] Fix regression with cluster reset (#4521) * Fix regression with cluster reset Signed-off-by: galal-hussein * typo Signed-off-by: galal-hussein --- pkg/cli/server/server.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 1f4551a279..77a683c801 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -174,17 +174,22 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont serverConfig.ControlConfig.DisableScheduler = true serverConfig.ControlConfig.DisableCCM = true + dataDir, err := datadir.LocalHome(cfg.DataDir, false) + if err != nil { + return err + } // delete local loadbalancers state for apiserver and supervisor servers - loadbalancer.ResetLoadBalancer(filepath.Join(cfg.DataDir, "agent"), loadbalancer.SupervisorServiceName) - loadbalancer.ResetLoadBalancer(filepath.Join(cfg.DataDir, "agent"), loadbalancer.APIServerServiceName) + loadbalancer.ResetLoadBalancer(filepath.Join(dataDir, "agent"), loadbalancer.SupervisorServiceName) + loadbalancer.ResetLoadBalancer(filepath.Join(dataDir, "agent"), loadbalancer.APIServerServiceName) // at this point we're doing a restore. Check to see if we've // passed in a token and if not, check if the token file exists. // If it doesn't, return an error indicating the token is necessary. if cfg.Token == "" { - if _, err := os.Stat(filepath.Join(cfg.DataDir, "server/token")); err != nil { + tokenFile := filepath.Join(dataDir, "server", "token") + if _, err := os.Stat(tokenFile); err != nil { if os.IsNotExist(err) { - return errors.New("") + return errors.New(tokenFile + " does not exist, please pass --token to complete the restoration") } } }