Skip to content

Commit

Permalink
Invoke cluster reset function when only reset flag is passed (k3s-io#…
Browse files Browse the repository at this point in the history
…3276)

Signed-off-by: galal-hussein <[email protected]>
Signed-off-by: Brian Downs <[email protected]>
  • Loading branch information
galal-hussein authored and briandowns committed May 19, 2021
1 parent a46a2c3 commit 599ab0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,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 {
Expand Down
6 changes: 1 addition & 5 deletions pkg/cli/cmds/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ type Agent struct {
EnableSELinux bool
ProtectKernelDefaults bool
AgentShared
ExtraKubeletArgs cli.StringSlice
ExtraKubeProxyArgs cli.StringSlice
Labels cli.StringSlice
Taints cli.StringSlice
PrivateRegistry string
ClusterReset bool
}

type AgentShared struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,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

Expand Down
7 changes: 5 additions & 2 deletions pkg/cluster/managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,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
Expand Down

0 comments on commit 599ab0a

Please sign in to comment.