Skip to content

Commit

Permalink
Relax version checking when using a custom K0sBinaryPath (#745)
Browse files Browse the repository at this point in the history
* Relax version checking when using a custom K0sBinaryPath

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Add a warning

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

* Flip condition

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

---------

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
  • Loading branch information
kke authored Aug 15, 2024
1 parent efd1308 commit 891ca56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions phase/validate_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
log "github.com/sirupsen/logrus"
)

// ValidateHosts performs remote OS detection
Expand Down Expand Up @@ -48,13 +49,22 @@ func (p *ValidateHosts) Run() error {

return p.parallelDo(
p.Config.Spec.Hosts,
p.warnK0sBinaryPath,
p.validateUniqueHostname,
p.validateUniqueMachineID,
p.validateUniquePrivateAddress,
p.validateSudo,
)
}

func (p *ValidateHosts) warnK0sBinaryPath(h *cluster.Host) error {
if h.Configurer.K0sBinaryPath() != "" {
log.Warnf("%s: k0s binary path is set to %q, version checking for the host is disabled. The k0s version for other hosts is %q.", h, h.Configurer.K0sBinaryPath(), p.Config.Spec.K0s.Version)
}

return nil
}

func (p *ValidateHosts) validateUniqueHostname(h *cluster.Host) error {
if p.hncount[h.Metadata.Hostname] > 1 {
return fmt.Errorf("hostname is not unique: %s", h.Metadata.Hostname)
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func (h *Host) UpdateK0sBinary(path string, version *version.Version) error {
if err != nil {
return fmt.Errorf("failed to get updated k0s binary version: %w", err)
}
if !version.Equal(updatedVersion) {
// verify the installed version matches the expected version, unless a custom k0sbinarypath is used
if h.K0sBinaryPath == "" && !version.Equal(updatedVersion) {
return fmt.Errorf("updated k0s binary version is %s not %s", updatedVersion, version)
}

Expand Down

0 comments on commit 891ca56

Please sign in to comment.