@@ -139,11 +139,11 @@ func (r *OpenStackMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req
139
139
140
140
// Handle deleted machines
141
141
if ! openStackMachine .DeletionTimestamp .IsZero () {
142
- return r .reconcileDelete (ctx , log , patchHelper , machine , openStackMachine , cluster , infraCluster )
142
+ return r .reconcileDelete (ctx , log , patchHelper , cluster , infraCluster , machine , openStackMachine )
143
143
}
144
144
145
145
// Handle non-deleted clusters
146
- return r .reconcileNormal (ctx , log , patchHelper , machine , openStackMachine , cluster , infraCluster )
146
+ return r .reconcileNormal (ctx , log , patchHelper , cluster , infraCluster , machine , openStackMachine )
147
147
}
148
148
149
149
func (r * OpenStackMachineReconciler ) SetupWithManager (ctx context.Context , mgr ctrl.Manager , options controller.Options ) error {
@@ -183,7 +183,7 @@ func (r *OpenStackMachineReconciler) SetupWithManager(ctx context.Context, mgr c
183
183
Complete (r )
184
184
}
185
185
186
- func (r * OpenStackMachineReconciler ) reconcileDelete (ctx context.Context , logger logr.Logger , patchHelper * patch.Helper , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) {
186
+ func (r * OpenStackMachineReconciler ) reconcileDelete (ctx context.Context , logger logr.Logger , patchHelper * patch.Helper , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine ) (ctrl.Result , error ) {
187
187
logger .Info ("Handling deleted OpenStackMachine" )
188
188
189
189
clusterName := fmt .Sprintf ("%s-%s" , cluster .ObjectMeta .Namespace , cluster .Name )
@@ -208,7 +208,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger
208
208
return ctrl.Result {}, err
209
209
}
210
210
if openStackCluster .Spec .ManagedAPIServerLoadBalancer {
211
- err = loadBalancerService .DeleteLoadBalancerMember (clusterName , machine , openStackMachine , openStackCluster )
211
+ err = loadBalancerService .DeleteLoadBalancerMember (openStackCluster , machine , openStackMachine , clusterName )
212
212
if err != nil {
213
213
return ctrl.Result {}, err
214
214
}
@@ -253,7 +253,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(ctx context.Context, logger
253
253
return ctrl.Result {}, nil
254
254
}
255
255
256
- func (r * OpenStackMachineReconciler ) reconcileNormal (ctx context.Context , logger logr.Logger , patchHelper * patch.Helper , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (_ ctrl.Result , reterr error ) {
256
+ func (r * OpenStackMachineReconciler ) reconcileNormal (ctx context.Context , logger logr.Logger , patchHelper * patch.Helper , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine ) (_ ctrl.Result , reterr error ) {
257
257
// If the OpenStackMachine is in an error state, return early.
258
258
if openStackMachine .Status .FailureReason != nil || openStackMachine .Status .FailureMessage != nil {
259
259
logger .Info ("Error state detected, skipping reconciliation" )
@@ -300,7 +300,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
300
300
return ctrl.Result {}, err
301
301
}
302
302
303
- instance , err := r .getOrCreate (computeService , machine , openStackMachine , cluster , openStackCluster , userData , logger )
303
+ instance , err := r .getOrCreate (logger , cluster , openStackCluster , machine , openStackMachine , computeService , userData )
304
304
if err != nil {
305
305
handleUpdateMachineError (logger , openStackMachine , errors .Errorf ("OpenStack instance cannot be created: %v" , err ))
306
306
return ctrl.Result {}, err
@@ -343,7 +343,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
343
343
}
344
344
345
345
if openStackCluster .Spec .ManagedAPIServerLoadBalancer {
346
- err = r .reconcileLoadBalancerMember (logger , osProviderClient , clientOpts , instance , clusterName , machine , openStackMachine , openStackCluster )
346
+ err = r .reconcileLoadBalancerMember (logger , osProviderClient , clientOpts , openStackCluster , machine , openStackMachine , instance , clusterName )
347
347
if err != nil {
348
348
handleUpdateMachineError (logger , openStackMachine , errors .Errorf ("LoadBalancerMember cannot be reconciled: %v" , err ))
349
349
return ctrl.Result {}, nil
@@ -365,15 +365,15 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
365
365
return ctrl.Result {}, nil
366
366
}
367
367
368
- func (r * OpenStackMachineReconciler ) getOrCreate (computeService * compute. Service , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster , userData string , logger logr. Logger ) (* infrav1.Instance , error ) {
368
+ func (r * OpenStackMachineReconciler ) getOrCreate (logger logr. Logger , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , computeService * compute. Service , userData string ) (* infrav1.Instance , error ) {
369
369
instance , err := computeService .InstanceExists (openStackMachine .Name )
370
370
if err != nil {
371
371
return nil , err
372
372
}
373
373
374
374
if instance == nil {
375
375
logger .Info ("Machine not exist, Creating Machine" , "Machine" , openStackMachine .Name )
376
- instance , err = computeService .InstanceCreate (cluster . Name , machine , openStackMachine , openStackCluster , userData )
376
+ instance , err = computeService .InstanceCreate (openStackCluster , machine , openStackMachine , cluster . Name , userData )
377
377
if err != nil {
378
378
return nil , errors .Errorf ("error creating Openstack instance: %v" , err )
379
379
}
@@ -390,14 +390,14 @@ func handleUpdateMachineError(logger logr.Logger, openstackMachine *infrav1.Open
390
390
logger .Error (fmt .Errorf (string (err )), message .Error ())
391
391
}
392
392
393
- func (r * OpenStackMachineReconciler ) reconcileLoadBalancerMember (logger logr.Logger , osProviderClient * gophercloud.ProviderClient , clientOpts * clientconfig.ClientOpts , instance * infrav1.Instance , clusterName string , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , openStackCluster * infrav1.OpenStackCluster ) error {
393
+ func (r * OpenStackMachineReconciler ) reconcileLoadBalancerMember (logger logr.Logger , osProviderClient * gophercloud.ProviderClient , clientOpts * clientconfig.ClientOpts , openStackCluster * infrav1.OpenStackCluster , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , instance * infrav1.Instance , clusterName string ) error {
394
394
ip := instance .IP
395
395
loadbalancerService , err := loadbalancer .NewService (osProviderClient , clientOpts , logger )
396
396
if err != nil {
397
397
return err
398
398
}
399
399
400
- return loadbalancerService .ReconcileLoadBalancerMember (clusterName , machine , openStackMachine , openStackCluster , ip )
400
+ return loadbalancerService .ReconcileLoadBalancerMember (openStackCluster , machine , openStackMachine , clusterName , ip )
401
401
}
402
402
403
403
// OpenStackClusterToOpenStackMachine is a handler.ToRequestsFunc to be used to enqeue requests for reconciliation
0 commit comments