Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phase/configure_k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (p *ConfigureK0s) Prepare(config *v1beta1.Cluster) error {
}

// DryRun prints the actions that would be taken
func (p *ConfigureK0s) DryRun() error {
func (p *ConfigureK0s) DryRun(_ context.Context) error {
for _, h := range p.hosts {
p.DryMsgf(h, "write k0s configuration to %s", h.Configurer.K0sConfigPath())
switch p.configSource {
Expand Down
6 changes: 3 additions & 3 deletions phase/disconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ func (p *Disconnect) Title() string {
}

// DryRun cleans up the temporary k0s binary from the hosts
func (p *Disconnect) DryRun() error {
_ = p.Config.Spec.Hosts.ParallelEach(context.Background(), func(_ context.Context, h *cluster.Host) error {
func (p *Disconnect) DryRun(ctx context.Context) error {
_ = p.Config.Spec.Hosts.ParallelEach(ctx, func(_ context.Context, h *cluster.Host) error {
if h.Metadata.K0sBinaryTempFile != "" && h.FS().FileExist(h.Metadata.K0sBinaryTempFile) {
_ = h.Sudo().FS().Remove(h.Metadata.K0sBinaryTempFile)
}
h.Metadata.K0sBinaryTempFile = ""
return nil
})
Comment on lines +20 to 27

return p.Run(context.TODO())
return p.Run(ctx)
}

// Run the phase
Expand Down
2 changes: 1 addition & 1 deletion phase/get_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var readKubeconfig = func(h *cluster.Host) (string, error) {
return output, nil
}

func (p *GetKubeconfig) DryRun() error {
func (p *GetKubeconfig) DryRun(_ context.Context) error {
p.DryMsg(p.Config.Spec.Hosts.Controllers()[0], "get admin kubeconfig")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions phase/install_binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (p *InstallBinaries) ShouldRun() bool {
}

// DryRun reports what would happen if Run is called.
func (p *InstallBinaries) DryRun() error {
func (p *InstallBinaries) DryRun(ctx context.Context) error {
return p.parallelDo(
context.Background(),
ctx,
p.Config.Spec.Hosts.Filter(func(h *cluster.Host) bool { return h.Metadata.K0sBinaryTempFile != "" }),
func(_ context.Context, h *cluster.Host) error {
p.DryMsgf(h, "install k0s %s binary from %s to %s", p.Config.Spec.K0s.Version, h.Metadata.K0sBinaryTempFile, h.K0sInstallLocation())
Expand Down
4 changes: 2 additions & 2 deletions phase/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type withmanager interface {
}

type withDryRun interface {
DryRun() error
DryRun(context.Context) error
}

// In-phase hooks for phases to run logic immediately before/after Run().
Expand Down Expand Up @@ -260,7 +260,7 @@ func (m *Manager) Run(ctx context.Context) error {

if dp, ok := p.(withDryRun); ok && m.DryRun {
ran = append(ran, p)
if err := dp.DryRun(); err != nil {
if err := dp.DryRun(ctx); err != nil {
result = err
return result
}
Expand Down
2 changes: 1 addition & 1 deletion phase/reset_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (p *ResetControllers) ShouldRun() bool {
}

// DryRun reports nodes that would get reset
func (p *ResetControllers) DryRun() error {
func (p *ResetControllers) DryRun(_ context.Context) error {
for _, h := range p.hosts {
p.DryMsg(h, "reset node")
}
Expand Down
2 changes: 1 addition & 1 deletion phase/reset_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (p *ResetLeader) Prepare(config *v1beta1.Cluster) error {
}

// DryRun reports that the host will be reset
func (p *ResetLeader) DryRun() error {
func (p *ResetLeader) DryRun(_ context.Context) error {
p.DryMsg(p.leader, "reset node")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion phase/reset_workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (p *ResetWorkers) ShouldRun() bool {
}

// DryRun reports the nodes will be reset
func (p *ResetWorkers) DryRun() error {
func (p *ResetWorkers) DryRun(_ context.Context) error {
for _, h := range p.hosts {
p.DryMsg(h, "node would be reset")
}
Expand Down
4 changes: 2 additions & 2 deletions phase/stage_binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (p *StageBinaries) ShouldRun() bool {
// not a permanent cluster change — on success, the temp file is removed by
// Disconnect (including its DryRun behavior), while CleanUp is only invoked on
// failure paths. CleanUp is also called here on error as an extra safety net.
func (p *StageBinaries) DryRun() error {
if err := p.Run(context.Background()); err != nil {
func (p *StageBinaries) DryRun(ctx context.Context) error {
if err := p.Run(ctx); err != nil {
p.CleanUp()
return err
}
Expand Down
Loading