Skip to content

Commit

Permalink
Missed a couple
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
  • Loading branch information
kke committed Feb 11, 2025
1 parent 56c5284 commit 336e071
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions phase/reinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func (p *Reinstall) Prepare(config *v1beta1.Cluster) error {

// ShouldRun is true when there are hosts that needs to be reinstalled
func (p *Reinstall) ShouldRun() bool {
return cluster.K0sForceFlagSince.Check(p.Config.Spec.K0s.Version) && len(p.hosts) > 0
return p.Config.Spec.K0s.Version.GreaterThanOrEqual(cluster.K0sForceFlagSince) && len(p.hosts) > 0
}

// Run the phase
func (p *Reinstall) Run() error {
if !cluster.K0sForceFlagSince.Check(p.Config.Spec.K0s.Version) {
if p.Config.Spec.K0s.Version.LessThan(cluster.K0sForceFlagSince) {
log.Warnf("k0s version %s does not support install --force flag, installFlags won't be reconfigured", p.Config.Spec.K0s.Version)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion phase/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (p *Restore) Prepare(config *v1beta1.Cluster) error {
}

// defined in backup.go
if !backupSinceVersion.Check(p.Config.Spec.K0s.Version) {
if p.Config.Spec.K0s.Version.LessThan(backupSinceVersion) {
return fmt.Errorf("the version of k0s on the host does not support restoring backups")
}

Expand Down
2 changes: 1 addition & 1 deletion phase/validate_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (p *ValidateHosts) Title() string {
// Run the phase
func (p *ValidateHosts) Run() error {
p.hncount = make(map[string]int, len(p.Config.Spec.Hosts))
if uniqueMachineIDVersion.Check(p.Config.Spec.K0s.Version) {
if p.Config.Spec.K0s.Version.LessThan(uniqueMachineIDSince) {
p.machineidcount = make(map[string]int, len(p.Config.Spec.Hosts))
}
p.privateaddrcount = make(map[string]int, len(p.Config.Spec.Hosts))
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
log "github.com/sirupsen/logrus"
)

var K0sForceFlagSince = version.MustConstraint(">= v1.27.4-0+k0s.0")
var K0sForceFlagSince = version.MustParse("v1.27.4+k0s.0")

// Host contains all the needed details to work with hosts
type Host struct {
Expand Down Expand Up @@ -329,7 +329,7 @@ func (h *Host) K0sInstallFlags() (Flags, error) {
}
}

if flags.Include("--force") && h.Metadata.K0sBinaryVersion != nil && !K0sForceFlagSince.Check(h.Metadata.K0sBinaryVersion) {
if flags.Include("--force") && h.Metadata.K0sBinaryVersion != nil && h.Metadata.K0sBinaryVersion.LessThan(K0sForceFlagSince) {
log.Warnf("%s: k0s version %s does not support the --force flag, ignoring it", h, h.Metadata.K0sBinaryVersion)
flags.Delete("--force")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func validateVersion(value interface{}) error {
return nil
}

if v.LessThan(v) {
if v.LessThan(k0sSupportedVersion) {
return fmt.Errorf("minimum supported k0s version is %s", k0sSupportedVersion)
}

Expand Down

0 comments on commit 336e071

Please sign in to comment.