Invoke cluster reset function when only reset flag is passed (#3276)

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
Hussein Galal 2021-05-05 17:40:04 +02:00 committed by GitHub
parent e1b9067d21
commit f410fc7d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -361,6 +361,11 @@ func setupTunnelAndRunAgent(ctx context.Context, nodeConfig *daemonconfig.Node,
case <-ctx.Done():
return ctx.Err()
}
} else if cfg.ClusterReset && proxy.IsAPIServerLBEnabled() {
if err := agent.Agent(&nodeConfig.AgentConfig); err != nil {
return err
}
agentRan = true
}
if err := tunnel.Setup(ctx, nodeConfig, proxy); err != nil {

View File

@ -43,6 +43,7 @@ type Agent struct {
Labels cli.StringSlice
Taints cli.StringSlice
AgentShared
ClusterReset bool
}
type AgentShared struct {

View File

@ -404,6 +404,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
agentConfig.Token = token
agentConfig.DisableLoadBalancer = !serverConfig.ControlConfig.DisableAPIServer
agentConfig.ETCDAgent = serverConfig.ControlConfig.DisableAPIServer
agentConfig.ClusterReset = serverConfig.ControlConfig.ClusterReset
agentConfig.Rootless = cfg.Rootless

View File

@ -70,9 +70,12 @@ func (c *Cluster) start(ctx context.Context) error {
if !os.IsNotExist(err) {
return err
}
} else {
return fmt.Errorf("cluster-reset was successfully performed, please remove the cluster-reset flag and start %s normally, if you need to perform another cluster reset, you must first manually delete the %s file", version.Program, resetFile)
rebootstrap := func() error {
return c.storageBootstrap(ctx)
}
return c.managedDB.Reset(ctx, rebootstrap)
}
return fmt.Errorf("cluster-reset was successfully performed, please remove the cluster-reset flag and start %s normally, if you need to perform another cluster reset, you must first manually delete the %s file", version.Program, resetFile)
}
// removing the reset file and ignore error if the file doesn't exist