From 33cda94704d975c0fb29be982e8c3ba855788389 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger <70865+arschles@users.noreply.github.com> Date: Fri, 30 Jul 2021 15:40:24 -0700 Subject: [PATCH] reformatting context and logger creation Signed-off-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com> --- exp/controllers/azuremachinepool_controller.go | 9 +++++---- exp/controllers/azuremachinepoolmachine_controller.go | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/exp/controllers/azuremachinepool_controller.go b/exp/controllers/azuremachinepool_controller.go index 55ae1d9c59c..66c0f40e099 100644 --- a/exp/controllers/azuremachinepool_controller.go +++ b/exp/controllers/azuremachinepool_controller.go @@ -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), @@ -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) diff --git a/exp/controllers/azuremachinepoolmachine_controller.go b/exp/controllers/azuremachinepoolmachine_controller.go index b4b34ba0a4f..4cdac3c59f6 100644 --- a/exp/controllers/azuremachinepoolmachine_controller.go +++ b/exp/controllers/azuremachinepoolmachine_controller.go @@ -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), @@ -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)