mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 06:56:29 +00:00
Remove n^2 algorithm. At 5000+ nodes plus this gets to be a real problem
This commit is contained in:
@@ -198,18 +198,17 @@ func ValidateHostCount(c *Cluster) error {
|
||||
}
|
||||
|
||||
func validateDuplicateNodes(c *Cluster) error {
|
||||
addresses := make(map[string]struct{}, len(c.Nodes))
|
||||
hostnames := make(map[string]struct{}, len(c.Nodes))
|
||||
for i := range c.Nodes {
|
||||
for j := range c.Nodes {
|
||||
if i == j {
|
||||
continue
|
||||
}
|
||||
if c.Nodes[i].Address == c.Nodes[j].Address {
|
||||
return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].Address)
|
||||
}
|
||||
if c.Nodes[i].HostnameOverride == c.Nodes[j].HostnameOverride {
|
||||
return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].HostnameOverride)
|
||||
}
|
||||
if _, ok := addresses[c.Nodes[i].Address]; ok {
|
||||
return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].Address)
|
||||
}
|
||||
addresses[c.Nodes[i].Address] = struct{}{}
|
||||
if _, ok := hostnames[c.Nodes[i].HostnameOverride]; ok {
|
||||
return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].HostnameOverride)
|
||||
}
|
||||
hostnames[c.Nodes[i].HostnameOverride] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user