Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore missing k0s binary on reset and avoid panic #465

Merged
merged 1 commit into from
Feb 22, 2023
Merged
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
9 changes: 1 addition & 8 deletions phase/reset_controllers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package phase

import (
"strings"

"github.com/Masterminds/semver"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
"github.com/k0sproject/rig/exec"
Expand Down Expand Up @@ -107,13 +104,9 @@ func (p *ResetControllers) Run() error {

log.Debugf("%s: resetting k0s...", h)
out, err := h.ExecOutput(h.Configurer.K0sCmdf("reset --data-dir=%s", h.DataDir), exec.Sudo(h))
c, _ := semver.NewConstraint("<= 1.22.3+k0s.0")
running, _ := semver.NewVersion(h.Metadata.K0sBinaryVersion)
if err != nil {
log.Debugf("%s: k0s reset failed: %s", h, out)
log.Warnf("%s: k0s reported failure: %v", h, err)
if c.Check(running) && !strings.Contains(out, "k0s cleanup operations done") {
log.Warnf("%s: k0s reset failed, trying k0s cleanup", h)
}
}
log.Debugf("%s: resetting k0s completed", h)

Expand Down
9 changes: 1 addition & 8 deletions phase/reset_leader.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package phase

import (
"strings"

"github.com/Masterminds/semver"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
"github.com/k0sproject/rig/exec"
Expand Down Expand Up @@ -53,13 +50,9 @@ func (p *ResetLeader) Run() error {

log.Debugf("%s: resetting k0s...", p.leader)
out, err := p.leader.ExecOutput(p.leader.Configurer.K0sCmdf("reset --data-dir=%s", p.leader.DataDir), exec.Sudo(p.leader))
c, _ := semver.NewConstraint("<= 1.22.3+k0s.0")
running, _ := semver.NewVersion(p.leader.Metadata.K0sBinaryVersion)
if err != nil {
log.Debugf("%s: k0s reset failed: %s", p.leader, out)
log.Warnf("%s: k0s reported failure: %v", p.leader, err)
if c.Check(running) && !strings.Contains(out, "k0s cleanup operations done") {
log.Warnf("%s: k0s reset failed, trying k0s cleanup", p.leader)
}
}
log.Debugf("%s: resetting k0s completed", p.leader)

Expand Down
9 changes: 1 addition & 8 deletions phase/reset_workers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package phase

import (
"strings"

"github.com/Masterminds/semver"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
"github.com/k0sproject/rig/exec"
Expand Down Expand Up @@ -98,13 +95,9 @@ func (p *ResetWorkers) Run() error {

log.Debugf("%s: resetting k0s...", h)
out, err := h.ExecOutput(h.Configurer.K0sCmdf("reset --data-dir=%s", h.DataDir), exec.Sudo(h))
c, _ := semver.NewConstraint("<= 1.22.3+k0s.0")
running, _ := semver.NewVersion(h.Metadata.K0sBinaryVersion)
if err != nil {
log.Debugf("%s: k0s reset failed: %s", h, out)
log.Warnf("%s: k0s reported failure: %v", h, err)
if c.Check(running) && !strings.Contains(out, "k0s cleanup operations done") {
log.Warnf("%s: k0s reset failed, trying k0s cleanup", h)
}
}
log.Debugf("%s: resetting k0s completed", h)

Expand Down