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
  • Loading branch information
Shawn Kaplan committed Oct 3, 2023
1 parent 6cccaa5 commit 9a4e9e7
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 101 deletions.
15 changes: 9 additions & 6 deletions controllers/route_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,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 @@ -194,7 +196,7 @@ func (r *RouteReconciler) reconcile(ctx context.Context, req ctrl.Request) error
r.eventRecorder.Event(route.K8sObject(), corev1.EventTypeNormal,
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)
}
err = updateRouteListenerStatus(ctx, r.client, route)
if err != nil {
Expand All @@ -206,6 +208,7 @@ func (r *RouteReconciler) reconcile(ctx context.Context, req ctrl.Request) error
}

// TODO delete metrics
r.log.Infow("reconciled", "name", req.Name)
return nil
} else {
r.log.Infow("reconcile, adding or updating", "name", req.Name)
Expand Down Expand Up @@ -255,7 +258,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 @@ -284,16 +287,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 @@ -334,7 +337,7 @@ func (r *RouteReconciler) buildAndDeployModel(

func (r *RouteReconciler) reconcileRouteResource(ctx context.Context, route core.Route) error {
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
9 changes: 5 additions & 4 deletions controllers/serviceexport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *ServiceExportReconciler) cleanupServiceExportResources(ctx context.Cont

func (r *ServiceExportReconciler) reconcileServiceExportResources(ctx context.Context, srvExport *mcs_api.ServiceExport) error {
if err := r.finalizerManager.AddFinalizers(ctx, srvExport, serviceExportFinalizer); err != nil {
r.eventRecorder.Event(srvExport, corev1.EventTypeWarning, k8s.GatewayEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %v", err))
r.eventRecorder.Event(srvExport, corev1.EventTypeWarning, k8s.GatewayEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %s", err))
return errors.New("TODO")
}

Expand All @@ -172,11 +172,12 @@ func (r *ServiceExportReconciler) buildAndDeployModel(
stack, targetGroup, 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 @@ -191,7 +192,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 nil, nil, err
}

Expand Down
8 changes: 5 additions & 3 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"
)

// ServiceImportReconciler reconciles a ServiceImport object
Expand Down Expand Up @@ -104,7 +106,7 @@ func (r *ServiceImportReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// Handle add
if err := r.finalizerManager.AddFinalizers(ctx, serviceImport, serviceImportFinalizer); err != nil {
r.eventRecorder.Event(serviceImport, corev1.EventTypeWarning, k8s.ServiceImportEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %v", err))
r.eventRecorder.Event(serviceImport, corev1.EventTypeWarning, k8s.ServiceImportEventReasonFailedAddFinalizer, fmt.Sprintf("Failed add finalizer due to %s", err))
return ctrl.Result{}, nil
}

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 @@ -61,7 +61,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 9a4e9e7

Please sign in to comment.