Skip to content

Commit

Permalink
reformatting context and logger creation
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Schlesinger <[email protected]>
  • Loading branch information
arschles committed Jul 30, 2021
1 parent ac73cf6 commit 33cda94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions exp/controllers/azuremachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg

// Reconcile idempotently gets, creates, and updates a machine pool.
func (ampr *AzureMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) {
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultedLoopTimeout(ampr.ReconcileTimeout))
defer cancel()

logger := ampr.Log.WithValues("namespace", req.Namespace, "azureMachinePool", req.Name)

ctx, span := tele.Tracer().Start(ctx, "controllers.AzureMachinePoolReconciler.Reconcile",
trace.WithAttributes(
attribute.String("namespace", req.Namespace),
Expand All @@ -166,10 +171,6 @@ func (ampr *AzureMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.
),
)
defer span.End()
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultedLoopTimeout(ampr.ReconcileTimeout))
defer cancel()

logger := ampr.Log.WithValues("namespace", req.Namespace, "azureMachinePool", req.Name)

azMachinePool := &infrav1exp.AzureMachinePool{}
err := ampr.Get(ctx, req.NamespacedName, azMachinePool)
Expand Down
7 changes: 4 additions & 3 deletions exp/controllers/azuremachinepoolmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con

// Reconcile idempotently gets, creates, and updates a machine pool.
func (ampmr *AzureMachinePoolMachineController) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) {
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultedLoopTimeout(ampmr.ReconcileTimeout))
defer cancel()
logger := ampmr.Log.WithValues("namespace", req.Namespace, "azureMachinePoolMachine", req.Name)

ctx, span := tele.Tracer().Start(ctx, "controllers.AzureMachinePoolMachineController.Reconcile",
trace.WithAttributes(
attribute.String("namespace", req.Namespace),
Expand All @@ -135,9 +139,6 @@ func (ampmr *AzureMachinePoolMachineController) Reconcile(ctx context.Context, r
),
)
defer span.End()
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultedLoopTimeout(ampmr.ReconcileTimeout))
defer cancel()
logger := ampmr.Log.WithValues("namespace", req.Namespace, "azureMachinePoolMachine", req.Name)

machine := &infrav1exp.AzureMachinePoolMachine{}
err := ampmr.Get(ctx, req.NamespacedName, machine)
Expand Down

0 comments on commit 33cda94

Please sign in to comment.