Skip to content

Commit 1c5bd9e

Browse files
authored
Strip domain from node.Name before matching with vm names (apache#47)
Signed-off-by: Hans Rakers <[email protected]>
1 parent 0150bf5 commit 1c5bd9e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cloudstack_loadbalancer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ func (cs *CSCloud) getLoadBalancer(service *corev1.Service) (*loadBalancer, erro
366366
func (cs *CSCloud) verifyHosts(nodes []*corev1.Node) ([]string, string, error) {
367367
hostNames := map[string]bool{}
368368
for _, node := range nodes {
369-
hostNames[strings.ToLower(node.Name)] = true
369+
// node.Name can be an FQDN as well, and CloudStack VM names aren't
370+
// To match, we need to Split the domain part off here, if present
371+
hostNames[strings.Split(strings.ToLower(node.Name), ".")[0]] = true
370372
}
371373

372374
p := cs.client.VirtualMachine.NewListVirtualMachinesParams()
@@ -397,6 +399,10 @@ func (cs *CSCloud) verifyHosts(nodes []*corev1.Node) ([]string, string, error) {
397399
}
398400
}
399401

402+
if len(hostIDs) == 0 || len(networkID) == 0 {
403+
return nil, "", fmt.Errorf("none of the hosts matched the list of VMs retrieved from CS API")
404+
}
405+
400406
return hostIDs, networkID, nil
401407
}
402408

0 commit comments

Comments
 (0)