@@ -165,12 +165,26 @@ func (m *MachinePoolScope) ListMachinePoolInstances(ctx context.Context) ([]core
165
165
CompartmentId : common .String (m .OCICluster .Spec .CompartmentId ),
166
166
InstancePoolId : common .String (poolOid ),
167
167
}
168
- resp , err := m .ComputeManagementClient .ListInstancePoolInstances (ctx , req )
169
- if err != nil {
170
- return nil , err
168
+
169
+ var instanceSummaries []core.InstanceSummary
170
+ listPoolInstances := func (ctx context.Context , request core.ListInstancePoolInstancesRequest ) (core.ListInstancePoolInstancesResponse , error ) {
171
+ return m .ComputeManagementClient .ListInstancePoolInstances (ctx , request )
171
172
}
173
+ for resp , err := listPoolInstances (ctx , req ); ; resp , err = listPoolInstances (ctx , req ) {
174
+ if err != nil {
175
+ return nil , err
176
+ }
177
+
178
+ instanceSummaries = append (instanceSummaries , resp .Items ... )
172
179
173
- return resp .Items , nil
180
+ if resp .OpcNextPage == nil {
181
+ break
182
+ } else {
183
+ req .Page = resp .OpcNextPage
184
+ }
185
+ }
186
+
187
+ return instanceSummaries , nil
174
188
}
175
189
176
190
// SetListandSetMachinePoolInstances retrieves a machine pools instances and sets them in the ProviderIDList
@@ -412,6 +426,31 @@ func (m *MachinePoolScope) ReconcileInstanceConfiguration(ctx context.Context) e
412
426
return nil
413
427
}
414
428
429
+ // ListInstancePoolSummaries list the core.InstancePoolSummary for the given core.ListInstancePoolsRequest
430
+ func (m * MachinePoolScope ) ListInstancePoolSummaries (ctx context.Context , req core.ListInstancePoolsRequest ) ([]core.InstancePoolSummary , error ) {
431
+ listInstancePools := func (ctx context.Context , request core.ListInstancePoolsRequest ) (core.ListInstancePoolsResponse , error ) {
432
+ return m .ComputeManagementClient .ListInstancePools (ctx , request )
433
+ }
434
+
435
+ var instancePoolSummaries []core.InstancePoolSummary
436
+ for resp , err := listInstancePools (ctx , req ); ; resp , err = listInstancePools (ctx , req ) {
437
+ if err != nil {
438
+ return instancePoolSummaries , errors .Wrapf (err , "failed to query OCIMachinePool by name" )
439
+ }
440
+
441
+ instancePoolSummaries = append (instancePoolSummaries , resp .Items ... )
442
+
443
+ if resp .OpcNextPage == nil {
444
+ // no more pages
445
+ break
446
+ } else {
447
+ req .Page = resp .OpcNextPage
448
+ }
449
+ }
450
+
451
+ return instancePoolSummaries , nil
452
+ }
453
+
415
454
// FindInstancePool attempts to find the instance pool by name and checks to make sure
416
455
// the instance pool was created by the cluster before returning the correct pool
417
456
func (m * MachinePoolScope ) FindInstancePool (ctx context.Context ) (* core.InstancePool , error ) {
@@ -422,18 +461,14 @@ func (m *MachinePoolScope) FindInstancePool(ctx context.Context) (*core.Instance
422
461
CompartmentId : common .String (m .OCICluster .Spec .CompartmentId ),
423
462
DisplayName : common .String (m .OCIMachinePool .GetName ()),
424
463
}
425
- respList , err := m .ComputeManagementClient .ListInstancePools (ctx , reqList )
426
- if err != nil {
427
- return nil , errors .Wrapf (err , "failed to query OCIMachinePool by name" )
428
- }
429
464
430
- if len ( respList . Items ) <= 0 {
431
- m . Info ( "No machine pool found" , "machinepool-name" , m . OCIMachinePool . GetName ())
432
- return nil , nil
465
+ instancePoolSummaries , err := m . ListInstancePoolSummaries ( ctx , reqList )
466
+ if err != nil {
467
+ return nil , err
433
468
}
434
469
435
470
var instancePoolSummary * core.InstancePoolSummary
436
- for _ , i := range respList . Items {
471
+ for _ , i := range instancePoolSummaries {
437
472
if m .IsResourceCreatedByClusterAPI (i .FreeformTags ) {
438
473
instancePoolSummary = & i
439
474
break
0 commit comments