@@ -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 {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,10 @@ 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 ()
293
- if err != nil {
294
- return ctrl.Result {}, fmt .Errorf ("failed CreateVPCLoadBalancerPoolMember %s: %w" , machineScope .IBMPowerVSMachine .Name , err )
295
- }
296
- if poolMember != nil && * poolMember .ProvisioningStatus != string (infrav1beta2 .VPCLoadBalancerStateActive ) {
297
- return ctrl.Result {RequeueAfter : 1 * time .Minute }, nil
309
+
310
+ if poolMemberReconcileResult , err := r .handleLoadBalancerPoolMemberConfiguration (machineScope ); err != nil || poolMemberReconcileResult .RequeueAfter > 0 {
311
+ return poolMemberReconcileResult , err
298
312
}
313
+
299
314
return ctrl.Result {}, nil
300
315
}
0 commit comments