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

Relax version checking when using a custom K0sBinaryPath #745

Merged
merged 2 commits into from
Aug 15, 2024
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
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
Loading