@@ -19,6 +19,7 @@ package controllers
1919import (
2020 "context"
2121 "fmt"
22+
2223 anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1"
2324 "github.com/aws/aws-application-networking-k8s/pkg/aws/services"
2425 "github.com/aws/aws-application-networking-k8s/pkg/controllers/eventhandlers"
@@ -90,7 +91,7 @@ func RegisterGatewayController(
9091 },
9192 })
9293 if err != nil {
93- log .Infof ("Could not setup default service network %s, proceeding without it - %s" ,
94+ log .Infof (context . TODO (), "Could not setup default service network %s, proceeding without it - %s" ,
9495 config .DefaultServiceNetwork , err .Error ())
9596 }
9697 }
@@ -109,7 +110,7 @@ func RegisterGatewayController(
109110 if ok {
110111 builder .Watches (& anv1alpha1.VpcAssociationPolicy {}, vpcAssociationPolicyEventHandler .MapToGateway ())
111112 } else {
112- log .Infof ("VpcAssociationPolicy CRD is not installed, skipping watch" )
113+ log .Infof (context . TODO (), "VpcAssociationPolicy CRD is not installed, skipping watch" )
113114 }
114115 return builder .Complete (r )
115116}
@@ -119,18 +120,22 @@ func RegisterGatewayController(
119120//+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gateways/finalizers,verbs=update
120121
121122func (r * gatewayReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
122- r .log .Infow ("reconcile" , "name" , req .Name )
123+ ctx = gwlog .StartReconcileTrace (ctx , r .log , "gateway" , req .Name , req .Namespace )
124+ defer func () {
125+ gwlog .EndReconcileTrace (ctx , r .log )
126+ }()
127+
123128 recErr := r .reconcile (ctx , req )
124129 if recErr != nil {
125- r .log .Infow ("reconcile error" , "name" , req .Name , "message" , recErr .Error ())
130+ r .log .Infow (ctx , "reconcile error" , "name" , req .Name , "message" , recErr .Error ())
126131 }
127132 res , retryErr := lattice_runtime .HandleReconcileError (recErr )
128133 if res .RequeueAfter != 0 {
129- r .log .Infow ("requeue request" , "name" , req .Name , "requeueAfter" , res .RequeueAfter )
134+ r .log .Infow (ctx , "requeue request" , "name" , req .Name , "requeueAfter" , res .RequeueAfter )
130135 } else if res .Requeue {
131- r .log .Infow ("requeue request" , "name" , req .Name )
136+ r .log .Infow (ctx , "requeue request" , "name" , req .Name )
132137 } else if retryErr == nil {
133- r .log .Infow ("reconciled" , "name" , req .Name )
138+ r .log .Infow (ctx , "reconciled" , "name" , req .Name )
134139 }
135140 return res , retryErr
136141}
@@ -149,12 +154,12 @@ func (r *gatewayReconciler) reconcile(ctx context.Context, req ctrl.Request) err
149154 }
150155
151156 if err := r .client .Get (ctx , gwClassName , gwClass ); err != nil {
152- r .log .Infow ("GatewayClass is not found" , "name" , req .Name , "gwclass" , gwClassName )
157+ r .log .Infow (ctx , "GatewayClass is not found" , "name" , req .Name , "gwclass" , gwClassName )
153158 return client .IgnoreNotFound (err )
154159 }
155160
156161 if gwClass .Spec .ControllerName != config .LatticeGatewayControllerName {
157- r .log .Infow ("GatewayClass is not recognized" , "name" , req .Name , "gwClassControllerName" , gwClass .Spec .ControllerName )
162+ r .log .Infow (ctx , "GatewayClass is not recognized" , "name" , req .Name , "gwClassControllerName" , gwClass .Spec .ControllerName )
158163 return nil
159164 }
160165
0 commit comments