From 658bb6e2cac0a8c5b36c6c0ac9a80a4d2487b412 Mon Sep 17 00:00:00 2001 From: xWink <45508693+xWink@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:44:00 -0700 Subject: [PATCH] Change unwanted error logs to debug, remove unwanted info logs, add route reconciler info logs, remove use of struct embedding in logs (#419) Co-authored-by: Shawn Kaplan --- controllers/route_controller.go | 16 ++- controllers/serviceexport_controller.go | 7 +- controllers/serviceimport_controller.go | 6 +- pkg/deploy/lattice/listener_manager.go | 2 - pkg/deploy/lattice/listener_synthesizer.go | 2 +- pkg/deploy/lattice/rule_synthesizer.go | 4 +- .../lattice/target_group_synthesizer.go | 126 ++++++++---------- pkg/gateway/model_build_lattice_service.go | 2 +- pkg/gateway/model_build_listener.go | 2 +- pkg/gateway/model_build_rule.go | 4 +- pkg/gateway/model_build_targetgroup.go | 3 +- 11 files changed, 78 insertions(+), 96 deletions(-) diff --git a/controllers/route_controller.go b/controllers/route_controller.go index e5301488..d8917117 100644 --- a/controllers/route_controller.go +++ b/controllers/route_controller.go @@ -165,6 +165,8 @@ func (r *routeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl } func (r *routeReconciler) reconcile(ctx context.Context, req ctrl.Request) error { + r.log.Infow("reconcile", "name", req.Name) + route, err := r.getRoute(ctx, req) if err != nil { return client.IgnoreNotFound(err) @@ -191,13 +193,14 @@ func (r *routeReconciler) reconcileDelete(ctx context.Context, req ctrl.Request, k8s.RouteEventReasonReconcile, "Deleting Reconcile") if err := r.cleanupRouteResources(ctx, route); err != nil { - return fmt.Errorf("failed to cleanup GRPCRoute %v, %v: %w", route.Name(), route.Namespace(), err) + return fmt.Errorf("failed to cleanup GRPCRoute %s, %s: %w", route.Name(), route.Namespace(), err) } if err := updateRouteListenerStatus(ctx, r.client, route); err != nil { return err } + r.log.Infow("reconciled", "name", req.Name) return r.finalizerManager.RemoveFinalizers(ctx, route.K8sObject(), routeTypeToFinalizer[r.routeType]) } @@ -239,7 +242,7 @@ func (r *routeReconciler) cleanupRouteResources(ctx context.Context, route core. func (r *routeReconciler) isRouteRelevant(ctx context.Context, route core.Route) bool { if len(route.Spec().ParentRefs()) == 0 { - r.log.Infof("Ignore Route which has no ParentRefs gateway %v ", route.Name()) + r.log.Infof("Ignore Route which has no ParentRefs gateway %s ", route.Name()) return false } @@ -268,16 +271,16 @@ func (r *routeReconciler) isRouteRelevant(ctx context.Context, route core.Route) } if err := r.client.Get(ctx, gwClassName, gwClass); err != nil { - r.log.Infof("Ignore Route not controlled by any GatewayClass %v, %v", route.Name(), route.Namespace()) + r.log.Infof("Ignore Route not controlled by any GatewayClass %s, %s", route.Name(), route.Namespace()) return false } if gwClass.Spec.ControllerName == config.LatticeGatewayControllerName { - r.log.Infof("Found aws-vpc-lattice for Route for %v, %v", route.Name(), route.Namespace()) + r.log.Infof("Found aws-vpc-lattice for Route for %s, %s", route.Name(), route.Namespace()) return true } - r.log.Infof("Ignore non aws-vpc-lattice Route %v, %v", route.Name(), route.Namespace()) + r.log.Infof("Ignore non aws-vpc-lattice Route %s, %s", route.Name(), route.Namespace()) return false } @@ -322,7 +325,7 @@ func (r *routeReconciler) reconcileUpsert(ctx context.Context, req ctrl.Request, k8s.RouteEventReasonReconcile, "Adding/Updating Reconcile") if err := r.finalizerManager.AddFinalizers(ctx, route.K8sObject(), routeTypeToFinalizer[r.routeType]); err != nil { - r.eventRecorder.Event(route.K8sObject(), corev1.EventTypeWarning, k8s.RouteEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %v", err)) + r.eventRecorder.Event(route.K8sObject(), corev1.EventTypeWarning, k8s.RouteEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %s", err)) } backendRefIPFamiliesErr := r.validateBackendRefsIpFamilies(ctx, route) @@ -367,6 +370,7 @@ func (r *routeReconciler) reconcileUpsert(ctx context.Context, req ctrl.Request, return err } + r.log.Infow("reconciled", "name", req.Name) return nil } diff --git a/controllers/serviceexport_controller.go b/controllers/serviceexport_controller.go index f0bf630b..406f42c1 100644 --- a/controllers/serviceexport_controller.go +++ b/controllers/serviceexport_controller.go @@ -150,11 +150,12 @@ func (r *serviceExportReconciler) buildAndDeployModel( stack, _, err := r.modelBuilder.Build(ctx, srvExport) if err != nil { - r.log.Infof("Failed to buildAndDeployModel for service export %v\n", srvExport) + r.log.Debugf("Failed to buildAndDeployModel for service export %s-%s due to %s", + srvExport.Name, srvExport.Namespace, err) r.eventRecorder.Event(srvExport, corev1.EventTypeWarning, k8s.GatewayEventReasonFailedBuildModel, - fmt.Sprintf("Failed BuildModel due to %v", err)) + fmt.Sprintf("Failed BuildModel due to %s", err)) // Build failed means the K8S serviceexport, service are NOT ready to be deployed to lattice // return nil to complete controller loop for current change. @@ -169,7 +170,7 @@ func (r *serviceExportReconciler) buildAndDeployModel( if err := r.stackDeployer.Deploy(ctx, stack); err != nil { r.eventRecorder.Event(srvExport, corev1.EventTypeWarning, - k8s.ServiceExportEventReasonFailedDeployModel, fmt.Sprintf("Failed deploy model due to %v", err)) + k8s.ServiceExportEventReasonFailedDeployModel, fmt.Sprintf("Failed deploy model due to %s", err)) return err } diff --git a/controllers/serviceimport_controller.go b/controllers/serviceimport_controller.go index 76d805a5..132fe9fa 100644 --- a/controllers/serviceimport_controller.go +++ b/controllers/serviceimport_controller.go @@ -19,10 +19,9 @@ package controllers import ( "context" "fmt" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/aws/aws-application-networking-k8s/pkg/k8s" - "github.com/aws/aws-application-networking-k8s/pkg/latticestore" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" @@ -30,6 +29,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" mcs_api "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + + "github.com/aws/aws-application-networking-k8s/pkg/k8s" + "github.com/aws/aws-application-networking-k8s/pkg/latticestore" ) type serviceImportReconciler struct { diff --git a/pkg/deploy/lattice/listener_manager.go b/pkg/deploy/lattice/listener_manager.go index ddb18e6e..ab5cc72f 100644 --- a/pkg/deploy/lattice/listener_manager.go +++ b/pkg/deploy/lattice/listener_manager.go @@ -145,8 +145,6 @@ func (d *defaultListenerManager) List(ctx context.Context, serviceID string) ([] return sdkListeners, err } - d.log.Debugf("Found listeners for service %v", resp.Items) - for _, r := range resp.Items { listener := vpclattice.ListenerSummary{ Arn: r.Arn, diff --git a/pkg/deploy/lattice/listener_synthesizer.go b/pkg/deploy/lattice/listener_synthesizer.go index 532ee68a..d660daba 100644 --- a/pkg/deploy/lattice/listener_synthesizer.go +++ b/pkg/deploy/lattice/listener_synthesizer.go @@ -59,7 +59,7 @@ func (l *listenerSynthesizer) Synthesize(ctx context.Context) error { // handle delete sdkListeners, err := l.getSDKListeners(ctx) if err != nil { - l.log.Errorf("Failed to get SDK Listeners during Listener synthesis due to err %s", err) + l.log.Debugf("Failed to get SDK Listeners during Listener synthesis due to err %s", err) } for _, sdkListener := range sdkListeners { diff --git a/pkg/deploy/lattice/rule_synthesizer.go b/pkg/deploy/lattice/rule_synthesizer.go index 97914513..8a522d81 100644 --- a/pkg/deploy/lattice/rule_synthesizer.go +++ b/pkg/deploy/lattice/rule_synthesizer.go @@ -39,7 +39,7 @@ func (r *ruleSynthesizer) Synthesize(ctx context.Context) error { err := r.stack.ListResources(&resRule) if err != nil { - r.log.Debugf("Error while synthesizing rules %v, %s", resRule, err) + r.log.Debugf("Error while listing rules %s", err) } updatePriority := false @@ -61,7 +61,7 @@ func (r *ruleSynthesizer) Synthesize(ctx context.Context) error { // handle delete sdkRules, err := r.getSDKRules(ctx) if err != nil { - r.log.Debugf("Error while getting rules %v, %s", sdkRules, err) + r.log.Debugf("Error while getting rules due to %s", err) } for _, sdkRule := range sdkRules { diff --git a/pkg/deploy/lattice/target_group_synthesizer.go b/pkg/deploy/lattice/target_group_synthesizer.go index a4b9c14a..0ee0bcd5 100644 --- a/pkg/deploy/lattice/target_group_synthesizer.go +++ b/pkg/deploy/lattice/target_group_synthesizer.go @@ -3,10 +3,12 @@ package lattice import ( "context" "errors" - "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/aws/aws-sdk-go/service/vpclattice" "strings" + "github.com/aws/aws-sdk-go/service/vpclattice" + + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" mcsv1alpha1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" @@ -48,8 +50,6 @@ type TargetGroupSynthesizer struct { func (t *TargetGroupSynthesizer) Synthesize(ctx context.Context) error { var ret = "" - t.log.Infof("Started synthesizing TargetGroups") - if err := t.SynthesizeTriggeredTargetGroup(ctx); err != nil { ret = LATTICE_RETRY } @@ -80,8 +80,6 @@ func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroup(ctx context.Cont t.stack.ListResources(&resTargetGroups) - t.log.Infof("Synthesize TargetGroups ==[%v]", resTargetGroups) - for _, resTargetGroup := range resTargetGroups { // find out VPC for service import @@ -114,10 +112,10 @@ func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroup(ctx context.Cont //Ingnore TG delete since this is an import from elsewhere continue } - tgStatus, err := t.targetGroupManager.Get(ctx, resTargetGroup) + tgStatus, err := t.targetGroupManager.Get(ctx, resTargetGroup) if err != nil { - t.log.Infof("Error on t.targetGroupManager.Get for %v err %v", resTargetGroup, err) + t.log.Debugf("Error getting target group: %s", err) returnErr = true continue } @@ -128,27 +126,23 @@ func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroup(ctx context.Cont resTargetGroup.Spec.Config.VpcID, tgStatus.TargetGroupARN, tgStatus.TargetGroupID, resTargetGroup.Spec.Config.IsServiceImport, "") - t.log.Infof("targetGroup Synthesized successfully for %s: %v", resTargetGroup.Spec.Name, tgStatus) - + t.log.Infof("Successfully synthesized target group %s with status %s", resTargetGroup.Spec.Name, tgStatus) } else { if resTargetGroup.Spec.IsDeleted { err := t.targetGroupManager.Delete(ctx, resTargetGroup) - if err != nil { returnErr = true continue } else { - t.log.Infof("Synthesizing Target Group: successfully deleted target group %v", resTargetGroup) + t.log.Debugf("Successfully deleted target group %s", resTargetGroup.Spec.Name) t.latticeDataStore.DelTargetGroup(resTargetGroup.Spec.Name, resTargetGroup.Spec.Config.K8SHTTPRouteName, false) } - } else { resTargetGroup.Spec.Config.VpcID = config.VpcID tgStatus, err := t.targetGroupManager.Create(ctx, resTargetGroup) - if err != nil { - t.log.Infof("Error on t.targetGroupManager.Create for %v err %v", resTargetGroup, err) + t.log.Debugf("Error creating target group: %s", err) returnErr = true continue } @@ -158,54 +152,46 @@ func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroup(ctx context.Cont tgStatus.TargetGroupID, resTargetGroup.Spec.Config.IsServiceImport, resTargetGroup.Spec.Config.K8SHTTPRouteName) - t.log.Infof("targetGroup Synthesized successfully for %v: %v", resTargetGroup.Spec, tgStatus) + t.log.Debugf("Successfully synthesized target group %s", resTargetGroup.Spec.Name) } } - } - t.log.Infof("Done -- SynthesizeTriggeredTargetGroup %v", resTargetGroups) - if returnErr { return errors.New("LATTICE-RETRY") } else { return nil } - } func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) error { var staleSDKTGs []model.TargetGroup sdkTGs, err := t.targetGroupManager.List(ctx) - if err != nil { - t.log.Debugf("SynthesizeSDKTargetGroups: failed to retrieve sdk TGs %v", err) + t.log.Errorf("Error listing target groups: %s", err) return nil } - t.log.Infof("SynthesizeSDKTargetGroups: here is sdkTGs %v len %v", sdkTGs, len(sdkTGs)) - for _, sdkTG := range sdkTGs { tgRouteName := "" if *sdkTG.getTargetGroupOutput.Config.VpcIdentifier != config.VpcID { - t.log.Infof("Ignore target group ARN %v Name %v for other VPCs", + t.log.Debugf("Ignoring target group %s (%s) because it is configured for other VPCs", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } // does target group have K8S tags, ignore if it is not tagged tgTags := sdkTG.targetGroupTags - if tgTags == nil || tgTags.Tags == nil { - t.log.Infof("Ignore target group not tagged for K8S, %v, %v", + t.log.Debugf("Ignoring target group %s (%s) because it is not tagged for K8S", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } parentRef, ok := tgTags.Tags[model.K8SParentRefTypeKey] if !ok || parentRef == nil { - t.log.Infof("Ignore target group that have no K8S parentRef tag :%v, %v", + t.log.Debugf("Ignoring target group %s (%s) because it has no K8S parentRef tag", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -213,7 +199,7 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) srvName, ok := tgTags.Tags[model.K8SServiceNameKey] if !ok || srvName == nil { - t.log.Infof("Ignore TargetGroup have no servicename tag: %v, %v", + t.log.Debugf("Ignoring target group %s (%s) because it has no servicename tag", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -221,7 +207,7 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) srvNamespace, ok := tgTags.Tags[model.K8SServiceNamespaceKey] if !ok || srvNamespace == nil { - t.log.Infof("Ignore TargetGroup have no servicenamespace tag: %v, %v", + t.log.Infof("Ignoring target group %s (%s) because it has no serviceNamespace tag", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -229,20 +215,16 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) // if its parentref is service export, check the parent service export exist // Ignore if service export exists if *parentRef == model.K8SServiceExportType { - t.log.Infof("TargetGroup %v, %v is referenced by ServiceExport", + t.log.Infof("TargetGroup %s (%s) is referenced by ServiceExport", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) - t.log.Infof("Determine serviceexport name=%v, namespace=%v exists for targetGroup %v", - *srvName, *srvNamespace, *sdkTG.getTargetGroupOutput.Arn) - srvExportName := types.NamespacedName{ Namespace: *srvNamespace, Name: *srvName, } srvExport := &mcsv1alpha1.ServiceExport{} if err := t.client.Get(ctx, srvExportName, srvExport); err == nil { - - t.log.Infof("Ignore TargetGroup(triggered by serviceexport) %v, %v since serviceexport object is found", + t.log.Debugf("Ignoring target group %s (%s), which was triggered by serviceexport, since serviceexport object is found", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -251,14 +233,13 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) // if its parentRef is a route, check that the parent route exists // Ignore if route does not exist if *parentRef == model.K8SHTTPRouteType { - t.log.Infof("TargetGroup %v, %v is referenced by a route", + t.log.Infof("Target group %s (%s) is referenced by a route", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) routeNameValue, ok := tgTags.Tags[model.K8SHTTPRouteNameKey] tgRouteName = *routeNameValue - if !ok || routeNameValue == nil { - t.log.Infof("Ignore TargetGroup(triggered by route) %v, %v has no route name tag", + t.log.Infof("Ignoring target group %s (%s), which was triggered by a route, because it has no route name tag", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -266,7 +247,7 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) routeNamespaceValue, ok := tgTags.Tags[model.K8SHTTPRouteNamespaceKey] if !ok || routeNamespaceValue == nil { - t.log.Infof("Ignore TargetGroup(triggered by route) %v, %v has no route namespace tag", + t.log.Infof("Ignoring target group %s (%s), which was triggered by a route, because it has no route namespace tag", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } @@ -279,11 +260,11 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) var route core.Route if *sdkTG.getTargetGroupOutput.Config.ProtocolVersion == vpclattice.TargetGroupProtocolVersionGrpc { if route, err = core.GetGRPCRoute(ctx, t.client, routeName); err != nil { - t.log.Infof("Could not find GRPCRoute for target group %s", err) + t.log.Errorf("Could not find GRPCRoute for target group %s", err) } } else { if route, err = core.GetHTTPRoute(ctx, t.client, routeName); err != nil { - t.log.Infof("Could not find HTTPRoute for target group %s", err) + t.log.Errorf("Could not find HTTPRoute for target group %s", err) } } @@ -295,22 +276,22 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) isUsed := t.isTargetGroupUsedByRoute(ctx, tgName, route) && len(sdkTG.getTargetGroupOutput.ServiceArns) > 0 if isUsed { - t.log.Infof("Ignore TargetGroup(triggered by route) %v, %v since route object is found", + t.log.Infof("Ignoring target group %s (%s), which was triggered by a route, since route object is found", *sdkTG.getTargetGroupOutput.Arn, *sdkTG.getTargetGroupOutput.Name) continue } else { - t.log.Infof("tgname %v is not used by route %v", tgName, route) + t.log.Infof("target group %s is not used by route %s-%s", tgName, route.Name(), route.Namespace()) } } } // the routename for serviceimport is "" if tg, err := t.latticeDataStore.GetTargetGroup(*sdkTG.getTargetGroupOutput.Name, "", true); err == nil { - t.log.Infof("Ignore target group created by service import %v", tg) + t.log.Debugf("Ignoring target group %s, which was created by service import", tg.TargetGroupKey.Name) continue } - t.log.Debugf("Append stale SDK TG to stale list Name %v, routename %v, ARN %v", + t.log.Debugf("Appending stale target group to stale list. Name: %s, routename: %s, ARN: %s", *sdkTG.getTargetGroupOutput.Name, tgRouteName, *sdkTG.getTargetGroupOutput.Id) staleSDKTGs = append(staleSDKTGs, model.TargetGroup{ @@ -325,28 +306,22 @@ func (t *TargetGroupSynthesizer) SynthesizeSDKTargetGroups(ctx context.Context) } - t.log.Infof("SynthesizeSDKTargetGroups, here is the stale target groups list %v stalelen %d", staleSDKTGs, len(staleSDKTGs)) - - ret_err := false + retErr := false for _, sdkTG := range staleSDKTGs { - err := t.targetGroupManager.Delete(ctx, &sdkTG) - t.log.Debugf("SynthesizeSDKTargetGroups, deleting stale target group %v", err) - if err != nil && !strings.Contains(err.Error(), "TargetGroup is referenced in routing configuration, listeners or rules of service.") { - ret_err = true + t.log.Debugf("Error deleting target group %s", err) + retErr = true } // continue on even when there is an err - } - if ret_err { + if retErr { return errors.New(LATTICE_RETRY) } else { return nil } - } func (t *TargetGroupSynthesizer) isTargetGroupUsedByRoute(ctx context.Context, tgName string, route core.Route) bool { @@ -378,30 +353,36 @@ func (t *TargetGroupSynthesizer) PostSynthesize(ctx context.Context) error { func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroupsCreation(ctx context.Context) error { var resTargetGroups []*model.TargetGroup var returnErr = false - t.stack.ListResources(&resTargetGroups) - t.log.Infof("SynthesizeTriggeredTargetGroupsCreation TargetGroups: [%v]", resTargetGroups) + err := t.stack.ListResources(&resTargetGroups) + if err != nil { + return err + } + for _, resTargetGroup := range resTargetGroups { if resTargetGroup.Spec.IsDeleted { - t.log.Infof("In the SynthesizeTriggeredTargetGroupsCreation(), we only handle TG Creation request and skip any deletion request [%v]", resTargetGroup) + t.log.Debugf("Ignoring deletion request for target group %s", resTargetGroup.Spec.Name) continue } + if resTargetGroup.Spec.Config.IsServiceImport { tgStatus, err := t.targetGroupManager.Get(ctx, resTargetGroup) if err != nil { - t.log.Infof("Error on t.targetGroupManager.Get for %v err %v", resTargetGroup, err) + t.log.Debugf("Error getting target group %s due to %s", resTargetGroup.Spec.Name, err) returnErr = true continue } + // for serviceimport, the httproutename is "" t.latticeDataStore.AddTargetGroup(resTargetGroup.Spec.Name, resTargetGroup.Spec.Config.VpcID, tgStatus.TargetGroupARN, tgStatus.TargetGroupID, resTargetGroup.Spec.Config.IsServiceImport, "") - t.log.Infof("targetGroup Synthesized successfully for %s: %v", resTargetGroup.Spec.Name, tgStatus) + + t.log.Debugf("Successfully synthesized target group %s with status %s", resTargetGroup.Spec.Name, tgStatus) } else { // handle TargetGroup creation request that triggered by httproute with backendref k8sService creation or serviceExport creation resTargetGroup.Spec.Config.VpcID = config.VpcID tgStatus, err := t.targetGroupManager.Create(ctx, resTargetGroup) if err != nil { - t.log.Infof("Error on t.targetGroupManager.Create for %v err %v", resTargetGroup, err) + t.log.Debugf("Error creating target group %s due to %s", resTargetGroup.Spec.Name, err) returnErr = true continue } @@ -411,43 +392,42 @@ func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroupsCreation(ctx con resTargetGroup.Spec.Config.VpcID, tgStatus.TargetGroupARN, tgStatus.TargetGroupID, resTargetGroup.Spec.Config.IsServiceImport, resTargetGroup.Spec.Config.K8SHTTPRouteName) - t.log.Infof("targetGroup Synthesized successfully for %v: %v", resTargetGroup.Spec, tgStatus) + + t.log.Debugf("Successfully synthesized target group %s with status %s", resTargetGroup.Spec.Name, tgStatus) } } - t.log.Infof("Done -- SynthesizeTriggeredTargetGroupsCreation %v", resTargetGroups) + if returnErr { return errors.New(LATTICE_RETRY) } else { return nil } - } func (t *TargetGroupSynthesizer) SynthesizeTriggeredTargetGroupsDeletion(ctx context.Context) error { var resTargetGroups []*model.TargetGroup var returnErr = false - t.stack.ListResources(&resTargetGroups) + err := t.stack.ListResources(&resTargetGroups) + if err != nil { + return err + } for _, resTargetGroup := range resTargetGroups { - t.log.Debugf("SynthesizeTriggeredTargetGroupsDeletion: TargetGroup ==[%v]", *resTargetGroup) - if !resTargetGroup.Spec.IsDeleted { - t.log.Infof("SynthesizeTriggeredTargetGroupsDeletion ignoring target group deletion request for tg: [%v]", resTargetGroup) + t.log.Infof("Ignoring target group %s because it is not deleted", resTargetGroup.Spec.Name) continue } if resTargetGroup.Spec.Config.IsServiceImport { - t.log.Debugf("Deleting service import target group from local datastore %v", resTargetGroup.Spec.LatticeID) + t.log.Debugf("Deleting service import target group from local datastore %s", resTargetGroup.Spec.LatticeID) t.latticeDataStore.DelTargetGroup(resTargetGroup.Spec.Name, resTargetGroup.Spec.Config.K8SHTTPRouteName, resTargetGroup.Spec.Config.IsServiceImport) } else { // For delete TargetGroup request triggered by k8s service, invoke vpc lattice api to delete it, if success, delete the tg in the datastore as well err := t.targetGroupManager.Delete(ctx, resTargetGroup) - t.log.Infof("err := t.targetGroupManager.Delete(ctx, resTargetGroup) err: %v", err) if err == nil { - t.log.Infof("Delete Target Group in SynthesizeTriggeredTargetGroupsDeletion: successfully deleted target group %v", resTargetGroup) t.latticeDataStore.DelTargetGroup(resTargetGroup.Spec.Name, resTargetGroup.Spec.Config.K8SHTTPRouteName, resTargetGroup.Spec.Config.IsServiceImport) } else { - t.log.Infof("Delete Target Group in SynthesizeTriggeredTargetGroupsDeletion: failed to delete target group %v, err %v", resTargetGroup, err) + t.log.Debugf("Error deleting target group %s due to %s", resTargetGroup.Spec.Name, err) returnErr = true } } diff --git a/pkg/gateway/model_build_lattice_service.go b/pkg/gateway/model_build_lattice_service.go index bee9728f..6ff4f16e 100644 --- a/pkg/gateway/model_build_lattice_service.go +++ b/pkg/gateway/model_build_lattice_service.go @@ -86,7 +86,7 @@ func (t *latticeServiceModelBuildTask) buildModel(ctx context.Context) error { } if err := t.buildTargetsForRoute(ctx); err != nil { - t.log.Errorf("failed to build targets due to %s", err) + t.log.Debugf("failed to build targets due to %s", err) } if err := t.buildListeners(ctx); err != nil { diff --git a/pkg/gateway/model_build_listener.go b/pkg/gateway/model_build_listener.go index d1928bc2..40a780b1 100644 --- a/pkg/gateway/model_build_listener.go +++ b/pkg/gateway/model_build_listener.go @@ -97,7 +97,7 @@ func (t *latticeServiceModelBuildTask) buildListeners(ctx context.Context) error t.latticeService.Spec.CustomerCertARN = certARN } - t.log.Debugf("Building Listener: found matching listner Port %v", port) + t.log.Debugf("Building Listener: found matching listner Port %d", port) if len(t.route.Spec().Rules()) == 0 { return fmt.Errorf("error building listener, there are no rules for route %s-%s", diff --git a/pkg/gateway/model_build_rule.go b/pkg/gateway/model_build_rule.go index ab3bad3e..7e055a52 100644 --- a/pkg/gateway/model_build_rule.go +++ b/pkg/gateway/model_build_rule.go @@ -42,7 +42,6 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { } for _, rule := range t.route.Spec().Rules() { - t.log.Debugf("Parsing http rule spec: %+v", rule) var ruleSpec model.RuleSpec if len(rule.Matches()) > 1 { @@ -170,8 +169,7 @@ func (t *latticeServiceModelBuildTask) updateRuleSpecWithHeaderMatches(match cor ruleSpec.NumOfHeaderMatches = len(match.Headers()) - t.log.Debugf("Examining match.Headers %v for route %s-%s", - match.Headers(), t.route.Name(), t.route.Namespace()) + t.log.Debugf("Examining match headers for route %s-%s", t.route.Name(), t.route.Namespace()) for i, header := range match.Headers() { t.log.Debugf("Examining match.Header: i = %d header.Type %s", i, *header.Type()) diff --git a/pkg/gateway/model_build_targetgroup.go b/pkg/gateway/model_build_targetgroup.go index f9b3498b..154f3636 100644 --- a/pkg/gateway/model_build_targetgroup.go +++ b/pkg/gateway/model_build_targetgroup.go @@ -94,7 +94,7 @@ func (t *svcExportTargetGroupModelBuildTask) run(ctx context.Context) error { err = t.BuildTargets(ctx) if err != nil { - t.log.Errorf("Failed to build targets for service export %s-%s due to %w", + t.log.Debugf("Failed to build targets for service export %s-%s due to %s", t.serviceExport.Name, t.serviceExport.Namespace, err) } @@ -255,7 +255,6 @@ func (t *latticeServiceModelBuildTask) buildTargetGroupsForRoute( } tg := model.NewTargetGroup(t.stack, tgName, tgSpec) - t.log.Infof("buildTargetGroupsForRoute, tg[%s], tgSpec%v \n", tgName, tg) t.tgByResID[tgName] = tg } }