Skip to content

Commit

Permalink
Strip domain from node.Name before matching with vm names
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Rakers <h.rakers@global.leaseweb.com>
  • Loading branch information
hrak committed Mar 12, 2024
1 parent 779b0ff commit 28481de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cloudstack_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ func (cs *CSCloud) getLoadBalancer(service *corev1.Service) (*loadBalancer, erro
func (cs *CSCloud) verifyHosts(nodes []*corev1.Node) ([]string, string, error) {
hostNames := map[string]bool{}
for _, node := range nodes {
hostNames[strings.ToLower(node.Name)] = true
// node.Name can be an FQDN as well, and CloudStack VM names aren't
// To match, we need to Split the domain part off here, if present
hostNames[strings.Split(strings.ToLower(node.Name), ".")[0]] = true
}

p := cs.client.VirtualMachine.NewListVirtualMachinesParams()
Expand Down Expand Up @@ -379,6 +381,10 @@ func (cs *CSCloud) verifyHosts(nodes []*corev1.Node) ([]string, string, error) {
}
}

if len(hostIDs) == 0 || len(networkID) == 0 {
return nil, "", fmt.Errorf("none of the hosts matched the list of VMs retrieved from CS API")
}

return hostIDs, networkID, nil
}

Expand Down

0 comments on commit 28481de

Please sign in to comment.