DaanHoogland commented on code in PR #102:
URL: 
https://github.com/apache/cloudstack-kubernetes-provider/pull/102#discussion_r3835879886


##########
cloudstack_loadbalancer.go:
##########
@@ -507,24 +524,37 @@ func (cs *CSCloud) verifyHosts(nodes []*corev1.Node) 
([]string, string, error) {
                p.SetProjectid(cs.projectID)
        }
 
-       l, err := cs.client.VirtualMachine.ListVirtualMachines(p)
+       vms, err := listAll(p, func() (int, []*cloudstack.VirtualMachine, 
error) {
+               l, err := cs.client.VirtualMachine.ListVirtualMachines(p)
+               if err != nil {
+                       return 0, nil, err
+               }
+
+               return l.Count, l.VirtualMachines, nil
+       })
        if err != nil {
                return nil, "", fmt.Errorf("error retrieving list of hosts: 
%v", err)
        }
 
        var hostIDs []string
        var networkID string
+       seen := map[string]bool{}
 
        // Check if the virtual machine is in the hosts slice, then add the 
corresponding ID.
-       for _, vm := range l.VirtualMachines {
-               if hostNames[strings.ToLower(vm.Name)] {
-                       if networkID != "" && networkID != vm.Nic[0].Networkid {
-                               return nil, "", fmt.Errorf("found hosts that 
belong to different networks")
-                       }
+       for _, vm := range vms {
+               // Paging over a set of VMs that is changing underneath us can 
return
+               // the same VM on more than one page.

Review Comment:
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to