@@ -198,6 +198,19 @@ 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
+ 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
+
201
214
func (r * IBMPowerVSMachineReconciler ) reconcileNormal (machineScope * scope.PowerVSMachineScope ) (ctrl.Result , error ) {
202
215
machineScope .Info ("Reconciling IBMPowerVSMachine" )
203
216
@@ -286,15 +299,15 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
286
299
machineScope .Info ("updating loadbalancer for machine" , "name" , machineScope .IBMPowerVSMachine .Name )
287
300
internalIP := machineScope .GetMachineInternalIP ()
288
301
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 )
290
303
return ctrl.Result {}, nil
291
304
}
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 )
298
309
}
310
+ machineScope .Info ("skipping loadbalancer configuration as it is not control plane machine" , "machineName" , machineScope .IBMPowerVSMachine .Name )
311
+
299
312
return ctrl.Result {}, nil
300
313
}
0 commit comments