This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/cloudstack-kubernetes-provider.git
The following commit(s) were added to refs/heads/main by this push:
new 1c5bd9e8 Strip domain from node.Name before matching with vm names
(#47)
1c5bd9e8 is described below
commit 1c5bd9e83c3704c023881bb395a04c954a54ff67
Author: Hans Rakers <[email protected]>
AuthorDate: Tue May 28 14:36:26 2024 +0200
Strip domain from node.Name before matching with vm names (#47)
Signed-off-by: Hans Rakers <[email protected]>
---
cloudstack_loadbalancer.go | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cloudstack_loadbalancer.go b/cloudstack_loadbalancer.go
index ed703339..ccd268d2 100644
--- a/cloudstack_loadbalancer.go
+++ b/cloudstack_loadbalancer.go
@@ -366,7 +366,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()
@@ -397,6 +399,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
}