@@ -135,11 +135,12 @@ func (r *OpenStackClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
135
135
}
136
136
137
137
// Handle non-deleted clusters
138
- return reconcileNormal (scope , cluster , openStackCluster )
138
+ return reconcileNormal (ctx , scope , cluster , openStackCluster )
139
139
}
140
140
141
141
func (r * OpenStackClusterReconciler ) reconcileDelete (ctx context.Context , scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) {
142
- scope .Logger ().Info ("Reconciling Cluster delete" )
142
+ log := ctrl .LoggerFrom (ctx )
143
+ log .Info ("Reconciling OpenStackCluster delete" )
143
144
144
145
// Wait for machines to be deleted before removing the finalizer as they
145
146
// depend on this resource to deprovision. Additionally it appears that
@@ -151,7 +152,7 @@ func (r *OpenStackClusterReconciler) reconcileDelete(ctx context.Context, scope
151
152
}
152
153
153
154
if len (machines ) != 0 {
154
- scope . Logger () .Info ("Waiting for machines to be deleted" , "remaining" , len (machines ))
155
+ log .Info ("Waiting for machines to be deleted" , "remaining" , len (machines ))
155
156
return ctrl.Result {RequeueAfter : 5 * time .Second }, nil
156
157
}
157
158
@@ -203,7 +204,7 @@ func (r *OpenStackClusterReconciler) reconcileDelete(ctx context.Context, scope
203
204
204
205
// Cluster is deleted so remove the finalizer.
205
206
controllerutil .RemoveFinalizer (openStackCluster , infrav1 .ClusterFinalizer )
206
- scope . Logger () .Info ("Reconciled Cluster deleted successfully" )
207
+ log .Info ("Reconciled Cluster deleted successfully" )
207
208
return ctrl.Result {}, nil
208
209
}
209
210
@@ -283,8 +284,9 @@ func deleteBastion(scope scope.Scope, cluster *clusterv1.Cluster, openStackClust
283
284
return nil
284
285
}
285
286
286
- func reconcileNormal (scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) { //nolint:unparam
287
- scope .Logger ().Info ("Reconciling Cluster" )
287
+ func reconcileNormal (ctx context.Context , scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) { //nolint:unparam
288
+ log := ctrl .LoggerFrom (ctx )
289
+ log .Info ("Reconciling Cluster" )
288
290
289
291
// If the OpenStackCluster doesn't have our finalizer, add it.
290
292
if controllerutil .AddFinalizer (openStackCluster , infrav1 .ClusterFinalizer ) {
@@ -297,12 +299,12 @@ func reconcileNormal(scope scope.Scope, cluster *clusterv1.Cluster, openStackClu
297
299
return reconcile.Result {}, err
298
300
}
299
301
300
- err = reconcileNetworkComponents (scope , cluster , openStackCluster )
302
+ err = reconcileNetworkComponents (ctx , scope , cluster , openStackCluster )
301
303
if err != nil {
302
304
return reconcile.Result {}, err
303
305
}
304
306
305
- result , err := reconcileBastion (scope , cluster , openStackCluster )
307
+ result , err := reconcileBastion (ctx , scope , cluster , openStackCluster )
306
308
if err != nil || ! reflect .DeepEqual (result , reconcile.Result {}) {
307
309
return result , err
308
310
}
@@ -330,12 +332,13 @@ func reconcileNormal(scope scope.Scope, cluster *clusterv1.Cluster, openStackClu
330
332
openStackCluster .Status .Ready = true
331
333
openStackCluster .Status .FailureMessage = nil
332
334
openStackCluster .Status .FailureReason = nil
333
- scope . Logger () .Info ("Reconciled Cluster created successfully" )
335
+ log .Info ("Reconciled Cluster created successfully" )
334
336
return reconcile.Result {}, nil
335
337
}
336
338
337
- func reconcileBastion (scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) {
338
- scope .Logger ().Info ("Reconciling Bastion" )
339
+ func reconcileBastion (ctx context.Context , scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) (ctrl.Result , error ) {
340
+ log := ctrl .LoggerFrom (ctx )
341
+ log .Info ("Reconciling Bastion" )
339
342
340
343
if openStackCluster .Spec .Bastion == nil || ! openStackCluster .Spec .Bastion .Enabled {
341
344
return reconcile.Result {}, deleteBastion (scope , cluster , openStackCluster )
@@ -385,7 +388,7 @@ func reconcileBastion(scope scope.Scope, cluster *clusterv1.Cluster, openStackCl
385
388
case infrav1 .InstanceStateError :
386
389
return ctrl.Result {}, fmt .Errorf ("failed to reconcile bastion, instance state is ERROR" )
387
390
case infrav1 .InstanceStateBuild , infrav1 .InstanceStateUndefined :
388
- scope . Logger () .Info ("Waiting for bastion instance to become ACTIVE" , "id" , instanceStatus .ID (), "status" , instanceStatus .State ())
391
+ log .Info ("Waiting for bastion instance to become ACTIVE" , "id" , instanceStatus .ID (), "status" , instanceStatus .State ())
389
392
return ctrl.Result {RequeueAfter : waitForBuildingInstanceToReconcile }, nil
390
393
case infrav1 .InstanceStateDeleted :
391
394
// This should normally be handled by deleteBastion
@@ -474,15 +477,17 @@ func bastionHashHasChanged(computeHash string, clusterAnnotations map[string]str
474
477
return latestHash != computeHash
475
478
}
476
479
477
- func reconcileNetworkComponents (scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) error {
480
+ func reconcileNetworkComponents (ctx context.Context , scope scope.Scope , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster ) error {
481
+ log := ctrl .LoggerFrom (ctx )
482
+
478
483
clusterName := fmt .Sprintf ("%s-%s" , cluster .Namespace , cluster .Name )
479
484
480
485
networkingService , err := networking .NewService (scope )
481
486
if err != nil {
482
487
return err
483
488
}
484
489
485
- scope . Logger () .Info ("Reconciling network components" )
490
+ log .Info ("Reconciling network components" )
486
491
487
492
err = networkingService .ReconcileExternalNetwork (openStackCluster )
488
493
if err != nil {
@@ -491,7 +496,7 @@ func reconcileNetworkComponents(scope scope.Scope, cluster *clusterv1.Cluster, o
491
496
}
492
497
493
498
if openStackCluster .Spec .NodeCIDR == "" {
494
- scope . Logger (). V ( 4 ) .Info ("No need to reconcile network, searching network and subnet instead" )
499
+ log .Info ("No need to reconcile network, searching network and subnet instead" )
495
500
496
501
netOpts := openStackCluster .Spec .Network .ToListOpt ()
497
502
networkList , err := networkingService .GetNetworksByFilter (& netOpts )
0 commit comments