Skip to content

Commit

Permalink
Change unwanted error logs to debug, remove unwanted info logs, add r…
Browse files Browse the repository at this point in the history
…oute reconciler info logs, remove use of struct embedding in logs (#419)

Co-authored-by: Shawn Kaplan <[email protected]>
  • Loading branch information
xWink and Shawn Kaplan authored Oct 3, 2023
1 parent 17dc47e commit 658bb6e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 96 deletions.
16 changes: 10 additions & 6 deletions controllers/route_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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])
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 4 additions & 3 deletions controllers/serviceexport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down
6 changes: 4 additions & 2 deletions controllers/serviceimport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ 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"
ctrl "sigs.k8s.io/controller-runtime"
"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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/deploy/lattice/listener_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/lattice/listener_synthesizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/lattice/rule_synthesizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 658bb6e

Please sign in to comment.