Skip to content

Commit

Permalink
Error out in ValidateHosts if all controllers are marked to be reset
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
  • Loading branch information
kke committed Dec 13, 2023
1 parent e21a773 commit 94b990e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions phase/validate_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ func (p *ValidateHosts) Run() error {
p.machineidcount = make(map[string]int, len(p.Config.Spec.Hosts))
p.privateaddrcount = make(map[string]int, len(p.Config.Spec.Hosts))

controllerCount := len(p.Config.Spec.Hosts.Controllers())
var resetControllerCount int
for _, h := range p.Config.Spec.Hosts {
p.hncount[h.Metadata.Hostname]++
p.machineidcount[h.Metadata.MachineID]++
if h.PrivateAddress != "" {
p.privateaddrcount[h.PrivateAddress]++
}
if h.IsController() {
resetControllerCount++
}
}

if resetControllerCount >= controllerCount {
return fmt.Errorf("all controllers are marked to be reset - this will break the cluster. use `k0sctl reset` instead if that is intentional")
}

return p.parallelDo(
Expand Down

0 comments on commit 94b990e

Please sign in to comment.