mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
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:
parent
e1b9067d21
commit
f410fc7d1e
@ -361,6 +361,11 @@ func setupTunnelAndRunAgent(ctx context.Context, nodeConfig *daemonconfig.Node,
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
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 {
|
if err := tunnel.Setup(ctx, nodeConfig, proxy); err != nil {
|
||||||
|
@ -43,6 +43,7 @@ type Agent struct {
|
|||||||
Labels cli.StringSlice
|
Labels cli.StringSlice
|
||||||
Taints cli.StringSlice
|
Taints cli.StringSlice
|
||||||
AgentShared
|
AgentShared
|
||||||
|
ClusterReset bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type AgentShared struct {
|
type AgentShared struct {
|
||||||
|
@ -404,6 +404,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
|
|||||||
agentConfig.Token = token
|
agentConfig.Token = token
|
||||||
agentConfig.DisableLoadBalancer = !serverConfig.ControlConfig.DisableAPIServer
|
agentConfig.DisableLoadBalancer = !serverConfig.ControlConfig.DisableAPIServer
|
||||||
agentConfig.ETCDAgent = serverConfig.ControlConfig.DisableAPIServer
|
agentConfig.ETCDAgent = serverConfig.ControlConfig.DisableAPIServer
|
||||||
|
agentConfig.ClusterReset = serverConfig.ControlConfig.ClusterReset
|
||||||
|
|
||||||
agentConfig.Rootless = cfg.Rootless
|
agentConfig.Rootless = cfg.Rootless
|
||||||
|
|
||||||
|
@ -70,9 +70,12 @@ func (c *Cluster) start(ctx context.Context) error {
|
|||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
rebootstrap := func() error {
|
||||||
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)
|
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
|
// removing the reset file and ignore error if the file doesn't exist
|
||||||
|
Loading…
Reference in New Issue
Block a user