@@ -198,6 +198,23 @@ func (r *IBMPowerVSMachineReconciler) getOrCreate(scope *scope.PowerVSMachineSco
198
198
return instance , err
199
199
}
200
200
201
+ // handleLoadBalancerPoolMemberConfiguration handles loadbalancer pool member creation flow.
202
+ func (r * IBMPowerVSMachineReconciler ) handleLoadBalancerPoolMemberConfiguration (machineScope * scope.PowerVSMachineScope ) (ctrl.Result , error ) {
203
+ if ! util .IsControlPlaneMachine (machineScope .Machine ) {
204
+ return ctrl.Result {}, nil
205
+ }
206
+ machineScope .Info ("Configuring control plane machine to backend LoadBalancer pool" , "machine name" , machineScope .IBMPowerVSMachine .Name )
207
+ poolMember , err := machineScope .CreateVPCLoadBalancerPoolMember ()
208
+ if err != nil {
209
+ return ctrl.Result {}, fmt .Errorf ("failed CreateVPCLoadBalancerPoolMember %s: %w" , machineScope .IBMPowerVSMachine .Name , err )
210
+ }
211
+ if poolMember != nil && * poolMember .ProvisioningStatus != string (infrav1beta2 .VPCLoadBalancerStateActive ) {
212
+ return ctrl.Result {Requeue : true , RequeueAfter : 1 * time .Minute }, nil
213
+ }
214
+
215
+ return ctrl.Result {}, nil
216
+ }
217
+
201
218
func (r * IBMPowerVSMachineReconciler ) reconcileNormal (machineScope * scope.PowerVSMachineScope ) (ctrl.Result , error ) {
202
219
machineScope .Info ("Reconciling IBMPowerVSMachine" )
203
220
@@ -289,12 +306,15 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
289
306
machineScope .Info ("Unable to update the LoadBalancer, Machine internal IP not yet set" , "machine name" , machineScope .IBMPowerVSMachine .Name )
290
307
return ctrl.Result {}, nil
291
308
}
292
- poolMember , err := machineScope .CreateVPCLoadBalancerPoolMember ()
309
+
310
+ poolMemberReconcileResult , err := r .handleLoadBalancerPoolMemberConfiguration (machineScope )
293
311
if err != nil {
294
- return ctrl.Result {}, fmt . Errorf ( "failed CreateVPCLoadBalancerPoolMember %s: %w" , machineScope . IBMPowerVSMachine . Name , err )
312
+ return ctrl.Result {}, err
295
313
}
296
- if poolMember != nil && * poolMember .ProvisioningStatus != string (infrav1beta2 .VPCLoadBalancerStateActive ) {
297
- return ctrl.Result {RequeueAfter : 1 * time .Minute }, nil
314
+
315
+ if poolMemberReconcileResult .Requeue {
316
+ return poolMemberReconcileResult , nil
298
317
}
318
+
299
319
return ctrl.Result {}, nil
300
320
}
0 commit comments