diff --git a/cloud/scope/load_balancer_reconciler.go b/cloud/scope/load_balancer_reconciler.go index a764e059..4d91e4ad 100644 --- a/cloud/scope/load_balancer_reconciler.go +++ b/cloud/scope/load_balancer_reconciler.go @@ -273,24 +273,34 @@ func (s *ClusterScope) GetLoadBalancers(ctx context.Context) (*loadbalancer.Load return nil, errors.New("cluster api tags have been modified out of context") } } - lbs, err := s.LoadBalancerClient.ListLoadBalancers(ctx, loadbalancer.ListLoadBalancersRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), - }) - if err != nil { - s.Logger.Error(err, "Failed to list lb by name") - return nil, errors.Wrap(err, "failed to list lb by name") - } + var page *string; + for { + lbs, err := s.LoadBalancerClient.ListLoadBalancers(ctx, loadbalancer.ListLoadBalancersRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "Failed to list lb by name") + return nil, errors.Wrap(err, "failed to list lb by name") + } - for _, lb := range lbs.Items { - if s.IsResourceCreatedByClusterAPI(lb.FreeformTags) { - resp, err := s.LoadBalancerClient.GetLoadBalancer(ctx, loadbalancer.GetLoadBalancerRequest{ - LoadBalancerId: lb.Id, - }) - if err != nil { - return nil, err + for _, lb := range lbs.Items { + if s.IsResourceCreatedByClusterAPI(lb.FreeformTags) { + resp, err := s.LoadBalancerClient.GetLoadBalancer(ctx, loadbalancer.GetLoadBalancerRequest{ + LoadBalancerId: lb.Id, + }) + if err != nil { + return nil, err + } + return &resp.LoadBalancer, nil } - return &resp.LoadBalancer, nil + } + + if lbs.OpcNextPage == nil { + break + } else { + page = lbs.OpcNextPage } } return nil, nil diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index 219939ab..b8e21212 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -323,18 +323,27 @@ func (m *MachineScope) getMachineFromOCID(ctx context.Context, instanceID *strin // GetMachineByDisplayName returns the machine from the compartment if there is a matching DisplayName, // and it was created by the cluster func (m *MachineScope) GetMachineByDisplayName(ctx context.Context, name string) (*core.Instance, error) { - req := core.ListInstancesRequest{DisplayName: common.String(name), - CompartmentId: common.String(m.getCompartmentId())} - resp, err := m.ComputeClient.ListInstances(ctx, req) - if err != nil { - return nil, err - } - if len(resp.Items) == 0 { - return nil, nil - } - for _, instance := range resp.Items { - if m.IsResourceCreatedByClusterAPI(instance.FreeformTags) { - return &instance, nil + var page *string; + for { + req := core.ListInstancesRequest{DisplayName: common.String(name), + CompartmentId: common.String(m.getCompartmentId()), Page: page} + resp, err := m.ComputeClient.ListInstances(ctx, req) + if err != nil { + return nil, err + } + if len(resp.Items) == 0 { + return nil, nil + } + for _, instance := range resp.Items { + if m.IsResourceCreatedByClusterAPI(instance.FreeformTags) { + return &instance, nil + } + } + + if resp.OpcNextPage == nil { + break + } else { + page = resp.OpcNextPage } } return nil, nil