@@ -198,6 +198,19 @@ func (r *IBMPowerVSMachineReconciler) getOrCreate(scope *scope.PowerVSMachineSco
198198 return instance , err
199199}
200200
201+ // handleLoadBalancerPoolMemberConfiguration handles loadbalancer pool member creation flow.
202+ func (r * IBMPowerVSMachineReconciler ) handleLoadBalancerPoolMemberConfiguration (machineScope * scope.PowerVSMachineScope ) (ctrl.Result , error ) {
203+ poolMember , err := machineScope .CreateVPCLoadBalancerPoolMember ()
204+ if err != nil {
205+ return ctrl.Result {}, fmt .Errorf ("failed to create loadbalancer pool member %s: %w" , machineScope .IBMPowerVSMachine .Name , err )
206+ }
207+ if poolMember != nil && * poolMember .ProvisioningStatus != string (infrav1beta2 .VPCLoadBalancerStateActive ) {
208+ return ctrl.Result {RequeueAfter : 1 * time .Minute }, nil
209+ }
210+
211+ return ctrl.Result {}, nil
212+ }
213+
201214func (r * IBMPowerVSMachineReconciler ) reconcileNormal (machineScope * scope.PowerVSMachineScope ) (ctrl.Result , error ) {
202215 machineScope .Info ("Reconciling IBMPowerVSMachine" )
203216
@@ -286,15 +299,15 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
286299 machineScope .Info ("updating loadbalancer for machine" , "name" , machineScope .IBMPowerVSMachine .Name )
287300 internalIP := machineScope .GetMachineInternalIP ()
288301 if internalIP == "" {
289- machineScope .Info ("Unable to update the LoadBalancer, Machine internal IP not yet set" , "machine name " , machineScope .IBMPowerVSMachine .Name )
302+ machineScope .Info ("Unable to update the LoadBalancer, Machine internal IP not yet set" , "machineName " , machineScope .IBMPowerVSMachine .Name )
290303 return ctrl.Result {}, nil
291304 }
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
305+
306+ if util .IsControlPlaneMachine (machineScope .Machine ) {
307+ machineScope .Info ("Configuring loadbalancer configuration for control plane machine" , "machineName" , machineScope .IBMPowerVSMachine .Name )
308+ return r .handleLoadBalancerPoolMemberConfiguration (machineScope )
298309 }
310+ machineScope .Info ("skipping loadbalancer configuration for worker machine" , "machineName" , machineScope .IBMPowerVSMachine .Name )
311+
299312 return ctrl.Result {}, nil
300313}
0 commit comments