Skip to content

Commit

Permalink
Clarify error even futher, allow using --force to try leaving automat…
Browse files Browse the repository at this point in the history
…ically

Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed May 20, 2024
1 parent 3debfb6 commit 4d24ddb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions phase/validate_facts.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ func (p *ValidateFacts) validateControllerSwap() error {
}
log.Debugf("%s: host is new, checking if etcd members list %+v already contains %s", h, p.Config.Metadata.EtcdMembers, h.PrivateAddress)
if slices.Contains(p.Config.Metadata.EtcdMembers, h.PrivateAddress) {
return fmt.Errorf("controller %s is listed as an existing etcd member but k0s is not found installed on it, host may have been replaced", h)
if Force {
leader := p.Config.Spec.K0sLeader()
if err := leader.Exec(leader.Configurer.K0sCmdf("etcd leave --peer-address %s", h.PrivateAddress)); err != nil {
return fmt.Errorf("controller %s is listed as an existing etcd member but k0s is not found installed on it, the host may have been replaced. attempted etcd leave for the address %s but it failed: %w", h, h.PrivateAddress, err)
}
} else {
return fmt.Errorf("controller %s is listed as an existing etcd member but k0s is not found installed on it, the host may have been replaced. check the host and use `k0s etcd leave --peer-address %s on a controller or re-run apply with --force", h, h.PrivateAddress)
}
} else {
log.Debugf("%s: no match, assuming its safe to install", h)
}
log.Debugf("%s: no match, assuming its safe to install", h)
}

return nil
Expand Down

0 comments on commit 4d24ddb

Please sign in to comment.