From 116140272c85435ae0ec8a36e5210fa88dc14e97 Mon Sep 17 00:00:00 2001 From: Shawn Kaplan Date: Thu, 28 Sep 2023 13:39:12 -0700 Subject: [PATCH] Final logging improvements, removed glog --- Makefile | 2 +- cmd/aws-application-networking-k8s/main.go | 3 - controllers/route_controller.go | 21 ++----- controllers/service_controller.go | 4 +- controllers/serviceexport_controller.go | 35 +++++------ go.mod | 1 - go.sum | 2 - pkg/aws/services/vpclattice.go | 7 --- pkg/deploy/lattice/targets_manager.go | 41 ++++++------- pkg/deploy/lattice/targets_manager_test.go | 11 ++-- pkg/deploy/lattice/targets_synthesizer.go | 39 ++++++------ .../lattice/targets_synthesizer_test.go | 3 +- pkg/deploy/stack_deployer.go | 33 ++++++---- pkg/gateway/model_build_lattice_service.go | 22 +++---- pkg/gateway/model_build_listener.go | 33 ++++------ pkg/gateway/model_build_rule.go | 60 +++++++------------ pkg/gateway/model_build_targetgroup.go | 51 +++++++--------- pkg/gateway/model_build_targets.go | 40 ++++++------- pkg/gateway/model_build_targets_test.go | 3 + pkg/latticestore/introspect.go | 21 +++---- test/go.mod | 3 +- test/go.sum | 21 +++---- 22 files changed, 195 insertions(+), 261 deletions(-) diff --git a/Makefile b/Makefile index bb9bc05e..39c92697 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ help: ## Display this help. .PHONY: run run: ## Run in development mode - go run cmd/aws-application-networking-k8s/main.go --debug -v 6 + go run cmd/aws-application-networking-k8s/main.go --debug .PHONY: presubmit diff --git a/cmd/aws-application-networking-k8s/main.go b/cmd/aws-application-networking-k8s/main.go index b37198a9..44449ac3 100644 --- a/cmd/aws-application-networking-k8s/main.go +++ b/cmd/aws-application-networking-k8s/main.go @@ -90,9 +90,6 @@ func main() { var probeAddr string var debug bool - // setup glog level - flag.Lookup("logtostderr").Value.Set("true") - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&debug, "debug", false, "enable debug mode") diff --git a/controllers/route_controller.go b/controllers/route_controller.go index 67888fcc..a325c05d 100644 --- a/controllers/route_controller.go +++ b/controllers/route_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" "fmt" + "github.com/aws/aws-application-networking-k8s/pkg/aws/services" "github.com/aws/aws-application-networking-k8s/pkg/utils" @@ -312,36 +313,26 @@ func (r *RouteReconciler) buildAndDeployModel( return nil, nil, err } - stackJSON, err := r.stackMarshaller.Marshal(stack) + _, err = r.stackMarshaller.Marshal(stack) if err != nil { - //TODO - r.log.Infof("error on r.stackMarshaller.Marshal error %s", err) + r.log.Errorf("error on r.stackMarshaller.Marshal error %s", err) } - r.log.Info("Successfully built model:", stackJSON, "") - if err := r.stackDeployer.Deploy(ctx, stack); err != nil { - r.log.Infof("RouteReconciler: Failed deploy %s due to err %s", route.Name(), err) - if errors.As(err, &lattice.RetryErr) { r.eventRecorder.Event(route.K8sObject(), corev1.EventTypeNormal, k8s.RouteEventReasonRetryReconcile, "retry reconcile...") - } else { r.eventRecorder.Event(route.K8sObject(), corev1.EventTypeWarning, - k8s.RouteEventReasonFailedDeployModel, fmt.Sprintf("Failed deploy model due to %v", err)) + k8s.RouteEventReasonFailedDeployModel, fmt.Sprintf("Failed deploy model due to %s", err)) } return nil, nil, err } - r.log.Info("Successfully deployed model") - return stack, latticeService, err } func (r *RouteReconciler) reconcileRouteResource(ctx context.Context, route core.Route) error { - r.log.Infof("Beginning -- reconcileRouteResource, [%v]", route) - 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)) } @@ -392,7 +383,7 @@ func (r *RouteReconciler) reconcileRouteResource(ctx context.Context, route core } func (r *RouteReconciler) updateRouteStatus(ctx context.Context, dns string, route core.Route) error { - r.log.Infof("updateRouteStatus: route name %s, namespace %s, dns %s", route.Name(), route.Namespace(), dns) + r.log.Debugf("Updating route %s-%s with DNS %s", route.Name(), route.Namespace(), dns) routeOld := route.DeepCopy() if len(route.K8sObject().GetAnnotations()) == 0 { @@ -437,7 +428,7 @@ func (r *RouteReconciler) updateRouteStatus(ctx context.Context, dns string, rou return fmt.Errorf("failed to update route status due to err %w", err) } - r.log.Infof("updateRouteStatus patched dns %v", dns) + r.log.Debugf("Successfully updated route %s-%s with DNS %s", route.Name(), route.Namespace(), dns) return nil } diff --git a/controllers/service_controller.go b/controllers/service_controller.go index 046ec6ad..c2a670aa 100644 --- a/controllers/service_controller.go +++ b/controllers/service_controller.go @@ -65,8 +65,8 @@ func RegisterServiceController( client := mgr.GetClient() scheme := mgr.GetScheme() evtRec := mgr.GetEventRecorderFor("service") - modelBuild := gateway.NewTargetsBuilder(client, cloud, datastore) - stackDeploy := deploy.NewTargetsStackDeploy(cloud, client, datastore) + modelBuild := gateway.NewTargetsBuilder(log, client, cloud, datastore) + stackDeploy := deploy.NewTargetsStackDeploy(log, cloud, client, datastore) stackMarshaller := deploy.NewDefaultStackMarshaller() sr := &serviceReconciler{ log: log, diff --git a/controllers/serviceexport_controller.go b/controllers/serviceexport_controller.go index 0f838e20..d32b9ce5 100644 --- a/controllers/serviceexport_controller.go +++ b/controllers/serviceexport_controller.go @@ -20,16 +20,17 @@ import ( "context" "errors" "fmt" - "github.com/aws/aws-application-networking-k8s/controllers/eventhandlers" + 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" "sigs.k8s.io/controller-runtime/pkg/source" mcs_api "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + "github.com/aws/aws-application-networking-k8s/controllers/eventhandlers" + "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1" "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/deploy" @@ -129,18 +130,17 @@ func (r *ServiceExportReconciler) reconcile(ctx context.Context, req ctrl.Reques } if srvExport.ObjectMeta.Annotations["multicluster.x-k8s.io/federation"] == "amazon-vpc-lattice" { - r.log.Infof("ServiceExportReconciler --- found matching service export --- %s\n", srvExport.Name) + r.log.Debugf("Found matching service export %s-%s", srvExport.Name, srvExport.Namespace) if !srvExport.DeletionTimestamp.IsZero() { - r.log.Info("Deleting") if err := r.cleanupServiceExportResources(ctx, srvExport); err != nil { - r.log.Infof("Failed to clean up service export %v, err :%v \n", srvExport, err) return err } - - r.log.Info("Successfully delete") - - r.finalizerManager.RemoveFinalizers(ctx, srvExport, serviceExportFinalizer) + err := r.finalizerManager.RemoveFinalizers(ctx, srvExport, serviceExportFinalizer) + if err != nil { + r.log.Errorf("Failed to remove finalizers for service export %s-%s due to %s", + srvExport.Name, srvExport.Namespace, err) + } return nil } @@ -165,9 +165,10 @@ func (r *ServiceExportReconciler) reconcileServiceExportResources(ctx context.Co return err } -func (r *ServiceExportReconciler) buildAndDeployModel(ctx context.Context, srvExport *mcs_api.ServiceExport) (core.Stack, *latticemodel.TargetGroup, error) { - gwLog := log.FromContext(ctx) - +func (r *ServiceExportReconciler) buildAndDeployModel( + ctx context.Context, + srvExport *mcs_api.ServiceExport, +) (core.Stack, *latticemodel.TargetGroup, error) { stack, targetGroup, err := r.modelBuilder.Build(ctx, srvExport) if err != nil { @@ -182,22 +183,18 @@ func (r *ServiceExportReconciler) buildAndDeployModel(ctx context.Context, srvEx // TODO continue deploy to trigger reconcile of stale SDK objects //return stack, targetGroup, nil } - r.log.Infof("buildAndDeployModel: stack=%v, targetgroup=%v, err = %v\n", stack, targetGroup, err) - - stackJSON, err := r.stackMarshaller.Marshal(stack) + _, err = r.stackMarshaller.Marshal(stack) if err != nil { - r.log.Infof("Error on marshalling serviceExport model for name: %v namespace: %v\n", srvExport.Name, srvExport.Namespace) + r.log.Errorf("Error on marshalling model for service export %s-%s", srvExport.Name, srvExport.Namespace) } - gwLog.Info("Successfully built model", stackJSON, "") - 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)) return nil, nil, err } - gwLog.Info("Successfully deployed model") + r.log.Debugf("Successfully deployed model for service export %s-%s", srvExport.Name, srvExport.Namespace) return stack, targetGroup, err } diff --git a/go.mod b/go.mod index 85c3aca8..10676d6d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.20 require ( github.com/aws/aws-sdk-go v1.44.321 github.com/go-logr/zapr v1.2.3 - github.com/golang/glog v1.0.0 github.com/golang/mock v1.6.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.24.1 diff --git a/go.sum b/go.sum index 5c8ec0a7..c3c23de6 100644 --- a/go.sum +++ b/go.sum @@ -211,8 +211,6 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/pkg/aws/services/vpclattice.go b/pkg/aws/services/vpclattice.go index 6e2e2b8a..a68508c3 100644 --- a/pkg/aws/services/vpclattice.go +++ b/pkg/aws/services/vpclattice.go @@ -11,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/vpclattice" "github.com/aws/aws-sdk-go/service/vpclattice/vpclatticeiface" - "github.com/golang/glog" ) //go:generate mockgen -destination vpclattice_mocks.go -package services github.com/aws/aws-application-networking-k8s/pkg/aws/services Lattice @@ -73,8 +72,6 @@ func NewDefaultLattice(sess *session.Session, region string) *defaultLattice { latticeSess = vpclattice.New(sess, aws.NewConfig().WithRegion(region).WithEndpoint(endpoint).WithMaxRetries(20)) - glog.V(2).Infoln("Lattice Service EndPoint:", endpoint) - return &defaultLattice{latticeSess} } @@ -196,11 +193,9 @@ func (d *defaultLattice) FindServiceNetwork(ctx context.Context, name string, op return false } if !acctIdMatches { - glog.V(6).Infoln("ServiceNetwork found but does not match account id", name, r.Arn, optionalAccountId) continue } - glog.V(6).Infoln("Found ServiceNetwork", name, r.Arn, optionalAccountId) tagsInput := vpclattice.ListTagsForResourceInput{ ResourceArn: r.Arn, } @@ -228,7 +223,6 @@ func (d *defaultLattice) FindServiceNetwork(ctx context.Context, name string, op return nil, err } if snMatch == nil { - glog.V(6).Infoln("Service network for account not found ", name, optionalAccountId) return nil, NewNotFoundError("Service network", name) } @@ -253,7 +247,6 @@ func (d *defaultLattice) FindService(ctx context.Context, nameProvider LatticeSe return nil, err } if svcMatch == nil { - glog.V(6).Infoln("Service not found", serviceName) return nil, NewNotFoundError("Service", serviceName) } diff --git a/pkg/deploy/lattice/targets_manager.go b/pkg/deploy/lattice/targets_manager.go index 747767ce..a77a32a5 100644 --- a/pkg/deploy/lattice/targets_manager.go +++ b/pkg/deploy/lattice/targets_manager.go @@ -4,14 +4,13 @@ import ( "context" "errors" - "github.com/golang/glog" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/vpclattice" lattice_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/latticestore" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) type TargetsManager interface { @@ -19,12 +18,18 @@ type TargetsManager interface { } type defaultTargetsManager struct { + log gwlog.Logger cloud lattice_aws.Cloud datastore *latticestore.LatticeDataStore } -func NewTargetsManager(cloud lattice_aws.Cloud, datastore *latticestore.LatticeDataStore) *defaultTargetsManager { +func NewTargetsManager( + log gwlog.Logger, + cloud lattice_aws.Cloud, + datastore *latticestore.LatticeDataStore, +) *defaultTargetsManager { return &defaultTargetsManager{ + log: log, cloud: cloud, datastore: datastore, } @@ -38,40 +43,36 @@ func NewTargetsManager(cloud lattice_aws.Cloud, datastore *latticestore.LatticeD // otherwise: // nil func (s *defaultTargetsManager) Create(ctx context.Context, targets *latticemodel.Targets) error { - glog.V(6).Infof("Update Lattice targets API call for %v \n", targets) + s.log.Debugf("Creating targets for target group %s-%s", targets.Spec.Name, targets.Spec.Namespace) // Need to find TargetGroup ID from datastore tgName := latticestore.TargetGroupName(targets.Spec.Name, targets.Spec.Namespace) tg, err := s.datastore.GetTargetGroup(tgName, targets.Spec.RouteName, false) // isServiceImport=false - if err != nil { - glog.V(6).Infof("Failed to Create targets, service ( name %v namespace %v) not found, retry later\n", targets.Spec.Name, targets.Spec.Namespace) + s.log.Debugf("Failed to Create targets, service %s-%s was not found, will retry later", + targets.Spec.Name, targets.Spec.Namespace) return errors.New(LATTICE_RETRY) } + vpcLatticeSess := s.cloud.Lattice() - // find out sdk target list listTargetsInput := vpclattice.ListTargetsInput{ TargetGroupIdentifier: &tg.ID, } - var delTargetsList []*vpclattice.Target listTargetsOutput, err := vpcLatticeSess.ListTargetsAsList(ctx, &listTargetsInput) - glog.V(6).Infof("TargetsManager-Create, listTargetsOutput %v, err %v \n", listTargetsOutput, err) if err != nil { - glog.V(6).Infof("Failed to create target, tgName %v tg %v\n", tgName, tg) return err } + for _, sdkT := range listTargetsOutput { // check if sdkT is in input target list isStale := true - for _, t := range targets.Spec.TargetIPList { if (aws.StringValue(sdkT.Id) == t.TargetIP) && (aws.Int64Value(sdkT.Port) == t.Port) { isStale = false break } } - if isStale { delTargetsList = append(delTargetsList, &vpclattice.Target{Id: sdkT.Id, Port: sdkT.Port}) } @@ -82,9 +83,12 @@ func (s *defaultTargetsManager) Create(ctx context.Context, targets *latticemode TargetGroupIdentifier: &tg.ID, Targets: delTargetsList, } - deRegisterTargetsOutput, err := vpcLatticeSess.DeregisterTargetsWithContext(ctx, &deRegisterTargetsInput) - glog.V(6).Infof("TargetManager-Create, deregister deleted targets input %v, output %v, err %v\n", deRegisterTargetsInput, deRegisterTargetsOutput, err) + _, err := vpcLatticeSess.DeregisterTargetsWithContext(ctx, &deRegisterTargetsInput) + if err != nil { + s.log.Errorf("Deregistering targets for target group %s failed due to %s", tg.ID, err) + } } + // TODO following should be done at model level var targetList []*vpclattice.Target for _, target := range targets.Spec.TargetIPList { @@ -106,21 +110,18 @@ func (s *defaultTargetsManager) Create(ctx context.Context, targets *latticemode TargetGroupIdentifier: &tg.ID, Targets: targetList, } - glog.V(6).Infof("Calling Lattice API register targets input %v \n", registerRouteInput) resp, err := vpcLatticeSess.RegisterTargetsWithContext(ctx, ®isterRouteInput) - glog.V(6).Infof("register pod to target group resp[%v]\n", resp) - glog.V(6).Infof("register pod to target group err[%v]\n", err) if err != nil { - glog.V(6).Infof("Fail to register target err[%v]\n", err) return err } isTargetRegisteredUnsuccessful := len(resp.Unsuccessful) > 0 if isTargetRegisteredUnsuccessful { - glog.V(6).Infof("Targets register unsuccessfully, will retry later\n") + s.log.Debugf("Failed to register targets for target group %s, will retry later", tg.ID) return errors.New(LATTICE_RETRY) } - glog.V(6).Infof("Targets register successfully\n") + + s.log.Debugf("Successfully registered targets for target group %s", tg.ID) return nil } diff --git a/pkg/deploy/lattice/targets_manager_test.go b/pkg/deploy/lattice/targets_manager_test.go index 6d03c621..21bcc5e0 100644 --- a/pkg/deploy/lattice/targets_manager_test.go +++ b/pkg/deploy/lattice/targets_manager_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-application-networking-k8s/pkg/model/core" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) /* @@ -67,7 +68,7 @@ func Test_RegisterTargets_RegisterSuccessfully(t *testing.T) { mockVpcLatticeSess.EXPECT().ListTargetsAsList(ctx, gomock.Any()).Return(listTargetOutput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - targetsManager := NewTargetsManager(mockCloud, latticeDataStore) + targetsManager := NewTargetsManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) err := targetsManager.Create(ctx, &createInput) assert.Nil(t, err) @@ -90,7 +91,7 @@ func Test_RegisterTargets_TGNotExist(t *testing.T) { latticeDataStore := latticestore.NewLatticeDataStore() mockCloud := mocks_aws.NewMockCloud(c) - targetsManager := NewTargetsManager(mockCloud, latticeDataStore) + targetsManager := NewTargetsManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) err := targetsManager.Create(ctx, &createInput) assert.NotNil(t, err) @@ -150,7 +151,7 @@ func Test_RegisterTargets_Registerfailed(t *testing.T) { mockVpcLatticeSess.EXPECT().RegisterTargetsWithContext(ctx, gomock.Any()).Return(registerTargetsOutput, errors.New("Register_Targets_Failed")) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - targetsManager := NewTargetsManager(mockCloud, latticeDataStore) + targetsManager := NewTargetsManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) err := targetsManager.Create(ctx, &planToRegister) assert.NotNil(t, err) @@ -234,7 +235,7 @@ func Test_RegisterTargets_RegisterUnsuccessfully(t *testing.T) { mockVpcLatticeSess.EXPECT().RegisterTargetsWithContext(ctx, ®isterTargetsInput).Return(registerTargetsOutput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - targetsManager := NewTargetsManager(mockCloud, latticeDataStore) + targetsManager := NewTargetsManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) err := targetsManager.Create(ctx, &planToRegister) assert.NotNil(t, err) @@ -271,7 +272,7 @@ func Test_RegisterTargets_NoTargets_NoCallRegisterTargets(t *testing.T) { mockVpcLatticeSess.EXPECT().RegisterTargetsWithContext(ctx, gomock.Any()).MaxTimes(0) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - targetsManager := NewTargetsManager(mockCloud, latticeDataStore) + targetsManager := NewTargetsManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) err := targetsManager.Create(ctx, &planToRegister) assert.Nil(t, err) diff --git a/pkg/deploy/lattice/targets_synthesizer.go b/pkg/deploy/lattice/targets_synthesizer.go index 93f77e12..869469f5 100644 --- a/pkg/deploy/lattice/targets_synthesizer.go +++ b/pkg/deploy/lattice/targets_synthesizer.go @@ -2,19 +2,24 @@ package lattice import ( "context" - "errors" "fmt" - "github.com/golang/glog" - lattice_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-application-networking-k8s/pkg/model/core" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) -func NewTargetsSynthesizer(cloud lattice_aws.Cloud, tgManager TargetsManager, stack core.Stack, latticeDataStore *latticestore.LatticeDataStore) *targetsSynthesizer { +func NewTargetsSynthesizer( + log gwlog.Logger, + cloud lattice_aws.Cloud, + tgManager TargetsManager, + stack core.Stack, + latticeDataStore *latticestore.LatticeDataStore, +) *targetsSynthesizer { return &targetsSynthesizer{ + log: log, cloud: cloud, targetsManager: tgManager, stack: stack, @@ -23,6 +28,7 @@ func NewTargetsSynthesizer(cloud lattice_aws.Cloud, tgManager TargetsManager, st } type targetsSynthesizer struct { + log gwlog.Logger cloud lattice_aws.Cloud targetsManager TargetsManager stack core.Stack @@ -31,30 +37,22 @@ type targetsSynthesizer struct { func (t *targetsSynthesizer) Synthesize(ctx context.Context) error { var resTargets []*latticemodel.Targets - - t.stack.ListResources(&resTargets) - glog.V(6).Infof("Synthesize Targets: %v \n", resTargets) - + err := t.stack.ListResources(&resTargets) + if err != nil { + t.log.Errorf("Failed to list targets due to %s", err) + } return t.SynthesizeTargets(ctx, resTargets) - } func (t *targetsSynthesizer) SynthesizeTargets(ctx context.Context, resTargets []*latticemodel.Targets) error { - for _, targets := range resTargets { err := t.targetsManager.Create(ctx, targets) - if err != nil { - errmsg := fmt.Sprintf("TargetSynthesize: Failed to create targets :%v , err:%v\n", targets, err) - glog.V(6).Infof("Errmsg: %s \n", errmsg) - return errors.New(errmsg) - + return fmt.Errorf("failed to synthesize targets due to %s", err) } tgName := latticestore.TargetGroupName(targets.Spec.Name, targets.Spec.Namespace) - var targetList []latticestore.Target - for _, target := range targets.Spec.TargetIPList { targetList = append(targetList, latticestore.Target{ TargetIP: target.TargetIP, @@ -62,11 +60,12 @@ func (t *targetsSynthesizer) SynthesizeTargets(ctx context.Context, resTargets [ }) } - t.latticeDataStore.UpdateTargetsForTargetGroup(tgName, targets.Spec.RouteName, targetList) - + err = t.latticeDataStore.UpdateTargetsForTargetGroup(tgName, targets.Spec.RouteName, targetList) + if err != nil { + t.log.Errorf("Failed to update targets for target group %s due to %s", tgName, err) + } } return nil - } func (t *targetsSynthesizer) synthesizeSDKTargets(ctx context.Context) error { diff --git a/pkg/deploy/lattice/targets_synthesizer_test.go b/pkg/deploy/lattice/targets_synthesizer_test.go index 83a633ab..a642fa6a 100644 --- a/pkg/deploy/lattice/targets_synthesizer_test.go +++ b/pkg/deploy/lattice/targets_synthesizer_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-application-networking-k8s/pkg/model/core" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) func Test_SynthesizeTargets(t *testing.T) { @@ -87,7 +88,7 @@ func Test_SynthesizeTargets(t *testing.T) { mockStack := core.NewDefaultStack(core.StackID(tgNamespacedName)) - targetsSynthesizer := NewTargetsSynthesizer(nil, mockTargetsManager, mockStack, ds) + targetsSynthesizer := NewTargetsSynthesizer(gwlog.FallbackLogger, nil, mockTargetsManager, mockStack, ds) targetsSpec := latticemodel.TargetsSpec{ Name: tt.srvExportName, diff --git a/pkg/deploy/stack_deployer.go b/pkg/deploy/stack_deployer.go index 4aaab3f5..9719e8be 100644 --- a/pkg/deploy/stack_deployer.go +++ b/pkg/deploy/stack_deployer.go @@ -96,7 +96,7 @@ func NewLatticeServiceStackDeploy( k8sClient: k8sClient, latticeServiceManager: lattice.NewServiceManager(cloud, latticeDataStore), targetGroupManager: lattice.NewTargetGroupManager(log, cloud), - targetsManager: lattice.NewTargetsManager(cloud, latticeDataStore), + targetsManager: lattice.NewTargetsManager(log, cloud, latticeDataStore), listenerManager: lattice.NewListenerManager(log, cloud, latticeDataStore), ruleManager: lattice.NewRuleManager(log, cloud, latticeDataStore), dnsEndpointManager: externaldns.NewDnsEndpointManager(log, k8sClient), @@ -106,7 +106,7 @@ func NewLatticeServiceStackDeploy( func (d *LatticeServiceStackDeployer) Deploy(ctx context.Context, stack core.Stack) error { targetGroupSynthesizer := lattice.NewTargetGroupSynthesizer(d.log, d.cloud, d.k8sClient, d.targetGroupManager, stack, d.latticeDataStore) - targetsSynthesizer := lattice.NewTargetsSynthesizer(d.cloud, d.targetsManager, stack, d.latticeDataStore) + targetsSynthesizer := lattice.NewTargetsSynthesizer(d.log, d.cloud, d.targetsManager, stack, d.latticeDataStore) serviceSynthesizer := lattice.NewServiceSynthesizer(d.log, d.latticeServiceManager, d.dnsEndpointManager, stack, d.latticeDataStore) listenerSynthesizer := lattice.NewListenerSynthesizer(d.log, d.listenerManager, stack, d.latticeDataStore) ruleSynthesizer := lattice.NewRuleSynthesizer(d.log, d.ruleManager, stack, d.latticeDataStore) @@ -177,25 +177,30 @@ func NewTargetGroupStackDeploy( func (d *LatticeTargetGroupStackDeployer) Deploy(ctx context.Context, stack core.Stack) error { synthesizers := []ResourceSynthesizer{ lattice.NewTargetGroupSynthesizer(d.log, d.cloud, d.k8sclient, d.targetGroupManager, stack, d.latticeDatastore), - lattice.NewTargetsSynthesizer(d.cloud, lattice.NewTargetsManager(d.cloud, d.latticeDatastore), stack, d.latticeDatastore), + lattice.NewTargetsSynthesizer(d.log, d.cloud, lattice.NewTargetsManager(d.log, d.cloud, d.latticeDatastore), stack, d.latticeDatastore), } return deploy(ctx, stack, synthesizers) } type latticeTargetsStackDeploy struct { - k8sclient client.Client + log gwlog.Logger + k8sClient client.Client stack core.Stack targetsManager lattice.TargetsManager latticeDataStore *latticestore.LatticeDataStore } -func NewTargetsStackDeploy(cloud aws.Cloud, k8sClient client.Client, latticeDataStore *latticestore.LatticeDataStore) *latticeTargetsStackDeploy { +func NewTargetsStackDeploy( + log gwlog.Logger, + cloud aws.Cloud, + k8sClient client.Client, + latticeDataStore *latticestore.LatticeDataStore, +) *latticeTargetsStackDeploy { return &latticeTargetsStackDeploy{ - k8sclient: k8sClient, - targetsManager: lattice.NewTargetsManager(cloud, latticeDataStore), + k8sClient: k8sClient, + targetsManager: lattice.NewTargetsManager(log, cloud, latticeDataStore), latticeDataStore: latticeDataStore, } - } func (d *latticeTargetsStackDeploy) Deploy(ctx context.Context, stack core.Stack) error { @@ -203,7 +208,10 @@ func (d *latticeTargetsStackDeploy) Deploy(ctx context.Context, stack core.Stack d.stack = stack - d.stack.ListResources(&resTargets) + err := d.stack.ListResources(&resTargets) + if err != nil { + d.log.Errorf("Failed to list targets due to %s", err) + } for _, targets := range resTargets { err := d.targetsManager.Create(ctx, targets) @@ -216,11 +224,12 @@ func (d *latticeTargetsStackDeploy) Deploy(ctx context.Context, stack core.Stack TargetIP: target.TargetIP, TargetPort: target.TargetPort, } - targetList = append(targetList, t) - } - d.latticeDataStore.UpdateTargetsForTargetGroup(tgName, targets.Spec.RouteName, targetList) + err := d.latticeDataStore.UpdateTargetsForTargetGroup(tgName, targets.Spec.RouteName, targetList) + if err != nil { + d.log.Errorf("Failed to update targets for target group %s due to %s", tgName, err) + } } } diff --git a/pkg/gateway/model_build_lattice_service.go b/pkg/gateway/model_build_lattice_service.go index 9e3f0488..ca88292d 100644 --- a/pkg/gateway/model_build_lattice_service.go +++ b/pkg/gateway/model_build_lattice_service.go @@ -77,38 +77,34 @@ func (t *latticeServiceModelBuildTask) run(ctx context.Context) error { func (t *latticeServiceModelBuildTask) buildModel(ctx context.Context) error { err := t.buildLatticeService(ctx) - if err != nil { - return fmt.Errorf("latticeServiceModelBuildTask: Failed on buildLatticeService %w", err) + return fmt.Errorf("failed to build lattice service due to %w", err) } _, err = t.buildTargetGroup(ctx, t.client) - if err != nil { - return fmt.Errorf("latticeServiceModelBuildTask: Failed on buildTargetGroup %w", err) + return fmt.Errorf("failed to build target group due to %w", err) } if !t.route.DeletionTimestamp().IsZero() { - t.log.Infof("latticeServiceModelBuildTask: for delete ignore Targets, policy %v\n", t.route) + t.log.Debugf("Ignoring building lattice service on delete for route %s-%s", t.route.Name(), t.route.Namespace()) return nil } err = t.buildTargets(ctx) - if err != nil { - t.log.Infof("latticeServiceModelBuildTask: Failed on building targets, error = %v\n ", err) + t.log.Errorf("failed to build targets due to %s", err) } + // only build listener when it is NOT delete case err = t.buildListener(ctx) - if err != nil { - return fmt.Errorf("latticeServiceModelBuildTask: Failed on building listener %w", err) + return fmt.Errorf("failed to build listener due to %w", err) } err = t.buildRules(ctx) - if err != nil { - return fmt.Errorf("latticeServiceModelBuildTask: Failed on building rule %w", err) + return fmt.Errorf("failed to build rule due to %w", err) } return nil @@ -139,10 +135,10 @@ func (t *latticeServiceModelBuildTask) buildLatticeService(ctx context.Context) // The 1st hostname will be used as lattice customer-domain-name spec.CustomerDomainName = string(t.route.Spec().Hostnames()[0]) - t.log.Infof("Setting customer-domain-name: %v for route %v-%v", + t.log.Infof("Setting customer-domain-name: %s for route %s-%s", spec.CustomerDomainName, t.route.Name(), t.route.Namespace()) } else { - t.log.Infof("No custom-domain-name for route :%v-%v", + t.log.Infof("No custom-domain-name for route %s-%s", t.route.Name(), t.route.Namespace()) spec.CustomerDomainName = "" } diff --git a/pkg/gateway/model_build_listener.go b/pkg/gateway/model_build_listener.go index e07707f5..4e5c799c 100644 --- a/pkg/gateway/model_build_listener.go +++ b/pkg/gateway/model_build_listener.go @@ -23,15 +23,15 @@ func (t *latticeServiceModelBuildTask) extractListenerInfo( ) (int64, string, string, error) { protocol := gateway_api.HTTPProtocolType if parentRef.SectionName != nil { - t.log.Infof("SectionName %s", *parentRef.SectionName) + t.log.Debugf("Listener parentRef SectionName is %s", *parentRef.SectionName) } - t.log.Infof("Building Listener for Route Name %s NameSpace %s", t.route.Name(), t.route.Namespace()) + t.log.Debugf("Building Listener for Route %s-%s", t.route.Name(), t.route.Namespace()) var gwNamespace = t.route.Namespace() if t.route.Spec().ParentRefs()[0].Namespace != nil { gwNamespace = string(*t.route.Spec().ParentRefs()[0].Namespace) } - t.log.Infof("build Listener, Parent Name %s Namespace %s", t.route.Spec().ParentRefs()[0].Name, gwNamespace) + var listenerPort = 0 gw := &gateway_api.Gateway{} gwName := types.NamespacedName{ @@ -40,16 +40,14 @@ func (t *latticeServiceModelBuildTask) extractListenerInfo( } if err := t.client.Get(ctx, gwName, gw); err != nil { - return 0, "", "", fmt.Errorf("failed to build Listener due to unknow http parent ref, Name %v, err %w", gwName, err) + return 0, "", "", fmt.Errorf("failed to build Listener due to unknow http parent ref, Name %s, err %w", gwName, err) } var certARN = "" // go through parent find out the matching section name if parentRef.SectionName != nil { - t.log.Infof("SectionName %s", *parentRef.SectionName) found := false for _, section := range gw.Spec.Listeners { - t.log.Infof("listener: %v", section) if section.Name == *parentRef.SectionName { listenerPort = int(section.Port) protocol = section.Protocol @@ -59,8 +57,7 @@ func (t *latticeServiceModelBuildTask) extractListenerInfo( if section.TLS.Mode != nil && *section.TLS.Mode == gateway_api.TLSModeTerminate { curCertARN, ok := section.TLS.Options[awsCustomCertARN] if ok { - t.log.Infof("Found certification %v under section %v", - curCertARN, section.Name) + t.log.Debugf("Found certification %s under section %s", curCertARN, section.Name) certARN = string(curCertARN) } } @@ -75,8 +72,6 @@ func (t *latticeServiceModelBuildTask) extractListenerInfo( // use 1st listener port // TODO check no listener if len(gw.Spec.Listeners) == 0 { - t.log.Infof("Error building listener, there is NO listeners on GW for %v", - gwName) return 0, "", "", errors.New("error building listener, there is NO listeners on GW") } listenerPort = int(gw.Spec.Listeners[0].Port) @@ -87,35 +82,35 @@ func (t *latticeServiceModelBuildTask) extractListenerInfo( } func (t *latticeServiceModelBuildTask) buildListener(ctx context.Context) error { - for _, parentRef := range t.route.Spec().ParentRefs() { if parentRef.Name != t.route.Spec().ParentRefs()[0].Name { // when a service is associate to multiple service network(s), all listener config MUST be same // so here we are only using the 1st gateway - t.log.Infof("Ignore parentref of different gateway %v", parentRef.Name) + t.log.Debugf("Ignore parentref of different gateway %s-%s", parentRef.Name, parentRef.Namespace) continue } port, protocol, certARN, err := t.extractListenerInfo(ctx, parentRef) - if err != nil { - t.log.Infof("Error on buildListener %v", err) return err } + if t.latticeService != nil { t.latticeService.Spec.CustomerCertARN = certARN } - t.log.Infof("Building Listener: found matching listner Port %v", port) + t.log.Debugf("Building Listener: found matching listner Port %v", port) if len(t.route.Spec().Rules()) == 0 { - return fmt.Errorf("error building listener, there are no rules for %v", t.route) + return fmt.Errorf("error building listener, there are no rules for route %s-%s", + t.route.Name(), t.route.Namespace()) } rule := t.route.Spec().Rules()[0] if len(rule.BackendRefs()) == 0 { - return fmt.Errorf("error building listener, there are no backend refs for %v", t.route) + return fmt.Errorf("error building listener, there are no backend refs for route %s-%s", + t.route.Name(), t.route.Namespace()) } backendRef := rule.BackendRefs()[0] @@ -147,11 +142,9 @@ func (t *latticeServiceModelBuildTask) buildListener(ctx context.Context) error } listenerResourceName := fmt.Sprintf("%s-%s-%d-%s", t.route.Name(), t.route.Namespace(), port, protocol) - t.log.Infof("listenerResourceName : %v", listenerResourceName) - + t.log.Infof("Creating new listener with name %s", listenerResourceName) latticemodel.NewListener(t.stack, listenerResourceName, port, protocol, t.route.Name(), t.route.Namespace(), action) } return nil - } diff --git a/pkg/gateway/model_build_rule.go b/pkg/gateway/model_build_rule.go index 94087a67..d603eda4 100644 --- a/pkg/gateway/model_build_rule.go +++ b/pkg/gateway/model_build_rule.go @@ -12,8 +12,9 @@ import ( gateway_api_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gateway_api_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" - latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" "github.com/aws/aws-sdk-go/service/vpclattice" + + latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" ) const ( @@ -38,29 +39,26 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { if parentRef.Name != t.route.Spec().ParentRefs()[0].Name { // when a service is associate to multiple service network(s), all listener config MUST be same // so here we are only using the 1st gateway - t.log.Infof("Ignore parentref of different gateway %v", parentRef.Name) - + t.log.Debugf("Ignore parentref of different gateway %s-%s", parentRef.Name, *parentRef.Namespace) continue } - port, protocol, _, err := t.extractListenerInfo(ctx, parentRef) + port, protocol, _, err := t.extractListenerInfo(ctx, parentRef) if err != nil { - t.log.Infof("Error on buildRules %v \n", err) return err } for _, rule := range t.route.Spec().Rules() { - t.log.Infof("Parsing http rule spec: %v\n", rule) + t.log.Debugf("Parsing http rule spec: %+v", rule) var ruleSpec latticemodel.RuleSpec if len(rule.Matches()) > 1 { // only support 1 match today - t.log.Infof("Do not support multiple matches: matches == %v ", len(rule.Matches())) return errors.New(LATTICE_NO_SUPPORT_FOR_MULTIPLE_MATCHES) } if len(rule.Matches()) == 0 { - t.log.Infof("Continue next rule, no matches specified in current rule") + t.log.Debugf("Continue next rule, no matches specified in current rule") continue } @@ -70,21 +68,21 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { switch m := match.(type) { case *core.HTTPRouteMatch: if m.Path() != nil && m.Path().Type != nil { - t.log.Infof("Examining pathmatch type %v value %v for for httproute %s namespace %s ", + t.log.Debugf("Examining pathmatch type %s value %s for for httproute %s-%s ", *m.Path().Type, *m.Path().Value, t.route.Name(), t.route.Namespace()) switch *m.Path().Type { case gateway_api_v1beta1.PathMatchExact: - t.log.Infof("Using PathMatchExact for httproute %s namespace %s ", + t.log.Debugf("Using PathMatchExact for httproute %s-%s ", t.route.Name(), t.route.Namespace()) ruleSpec.PathMatchExact = true case gateway_api_v1beta1.PathMatchPathPrefix: - t.log.Infof("Using PathMatchPathPrefix for httproute %s namespace %s ", + t.log.Debugf("Using PathMatchPathPrefix for httproute %s-%s ", t.route.Name(), t.route.Namespace()) ruleSpec.PathMatchPrefix = true default: - t.log.Infof("Unsupported path match type %v for httproute %s namespace %s", + t.log.Debugf("Unsupported path match type %s for httproute %s-%s", *m.Path().Type, t.route.Name(), t.route.Namespace()) return errors.New(LATTICE_UNSUPPORTED_PATH_MATCH_TYPE) } @@ -93,7 +91,7 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { // method based match if m.Method() != nil { - t.log.Infof("Examining http method %v for httproute %v namespace %v", + t.log.Infof("Examining http method %s for httproute %s-%s", *m.Method(), t.route.Name(), t.route.Namespace()) ruleSpec.Method = string(*m.Method()) @@ -101,12 +99,12 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { // controller does not support query matcher type today if m.QueryParams() != nil { - t.log.Infof("Unsupported match type for httproute %v, namespace %v", + t.log.Infof("Unsupported match type for httproute %s, namespace %s", t.route.Name(), t.route.Namespace()) return errors.New(LATTICE_UNSUPPORTED_MATCH_TYPE) } case *core.GRPCRouteMatch: - t.log.Infof("Building rule with GRPCRouteMatch, %v", *m) + t.log.Debugf("Building rule with GRPCRouteMatch, %+v", *m) ruleSpec.Method = string(gateway_api_v1beta1.HTTPMethodPost) method := m.Method() // VPC Lattice doesn't support suffix/regex matching, so we can't support method match without service @@ -116,20 +114,20 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { switch *method.Type { case gateway_api_v1alpha2.GRPCMethodMatchExact: if method.Service == nil { - t.log.Infof("Match all paths due to nil service and nil method") + t.log.Debugf("Match all paths due to nil service and nil method") ruleSpec.PathMatchPrefix = true ruleSpec.PathMatchValue = "/" } else if method.Method == nil { - t.log.Infof("Match by specific gRPC service %s, regardless of method", *method.Service) + t.log.Debugf("Match by specific gRPC service %s, regardless of method", *method.Service) ruleSpec.PathMatchPrefix = true ruleSpec.PathMatchValue = fmt.Sprintf("/%s/", *method.Service) } else { - t.log.Infof("Match by specific gRPC service %s and method %s", *method.Service, *method.Method) + t.log.Debugf("Match by specific gRPC service %s and method %s", *method.Service, *method.Method) ruleSpec.PathMatchExact = true ruleSpec.PathMatchValue = fmt.Sprintf("/%s/%s", *method.Service, *method.Method) } default: - return fmt.Errorf("unsupported gRPC method match type %v", *method.Type) + return fmt.Errorf("unsupported gRPC method match type %s", *method.Type) } default: return fmt.Errorf("unsupported rule match: %T", m) @@ -144,42 +142,30 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { ruleSpec.NumOfHeaderMatches = len(match.Headers()) - t.log.Infof("Examining match.Headers %v for route %s, namespace %s", + t.log.Debugf("Examining match.Headers %v for route %s-%s", match.Headers(), t.route.Name(), t.route.Namespace()) for i, header := range match.Headers() { - t.log.Infof("Examining match.Header: i = %d header.Type %v", i, *header.Type()) + t.log.Debugf("Examining match.Header: i = %d header.Type %s", i, *header.Type()) if header.Type() != nil && *header.Type() != gateway_api_v1beta1.HeaderMatchExact { - t.log.Infof("Unsupported header matchtype %v for httproute %v namespace %s", + t.log.Debugf("Unsupported header matchtype %s for httproute %s-%s", *header.Type(), t.route.Name(), t.route.Namespace()) return errors.New(LATTICE_UNSUPPORTED_HEADER_MATCH_TYPE) } - t.log.Infof("Found HeaderExactMatch==%v for HTTPRoute %v, namespace %v", - header.Value(), t.route.Name(), t.route.Namespace()) - matchType := vpclattice.HeaderMatchType{ Exact: aws.String(header.Value()), } ruleSpec.MatchedHeaders[i].Match = &matchType headerName := header.Name() - - t.log.Infof("Found matching i = %d headerName %v", i, &headerName) - ruleSpec.MatchedHeaders[i].Name = &headerName } } - t.log.Infof("Generated ruleSpec is: %v", ruleSpec) - - tgList := []*latticemodel.RuleTargetGroup{} + var tgList []*latticemodel.RuleTargetGroup for _, backendRef := range rule.BackendRefs() { - t.log.Infof("buildRoutingPolicy - examining backendRef %v, backendRef kind: %v", - backendRef, *backendRef.Kind()) - ruleTG := latticemodel.RuleTargetGroup{} - if string(*backendRef.Kind()) == "Service" { namespace := t.route.Namespace() if backendRef.Namespace() != nil { @@ -192,12 +178,10 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { if backendRef.Weight() != nil { ruleTG.Weight = int64(*backendRef.Weight()) } - } if string(*backendRef.Kind()) == "ServiceImport" { // TODO - t.log.Infof("Handle ServiceImport Routing Policy\n") /* I think this need to be done at policy manager API call tg, err := t.datastore.GetTargetGroup(string(backendRef.Name()), "default", true) // isServiceImport==true @@ -220,7 +204,6 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { if backendRef.Weight() != nil { ruleTG.Weight = int64(*backendRef.Weight()) } - } tgList = append(tgList, &ruleTG) @@ -233,7 +216,6 @@ func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error { latticemodel.NewRule(t.stack, ruleIDName, t.route.Name(), t.route.Namespace(), port, protocol, ruleAction, ruleSpec) ruleID++ - } } diff --git a/pkg/gateway/model_build_targetgroup.go b/pkg/gateway/model_build_targetgroup.go index c1183bce..7d483a6d 100644 --- a/pkg/gateway/model_build_targetgroup.go +++ b/pkg/gateway/model_build_targetgroup.go @@ -7,8 +7,6 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -110,17 +108,15 @@ func (t *targetGroupModelBuildTask) run(ctx context.Context) error { // for serviceexport func (t *targetGroupModelBuildTask) buildModel(ctx context.Context) error { err := t.BuildTargetGroupForServiceExport(ctx) - if err != nil { - return fmt.Errorf("failed to build TargetGroup when serviceExport buildModel for name %v namespace %v, %w", + return fmt.Errorf("failed to build target group for service export %s-%s due to %w", t.serviceExport.Name, t.serviceExport.Namespace, err) } err = t.BuildTargets(ctx) - if err != nil { - t.log.Infof("Failed to build Targets when serviceExport buildModel for name %v namespace %v", - t.serviceExport.Name, t.serviceExport.Namespace) + t.log.Errorf("Failed to build targets for service export %s-%s due to %w", + t.serviceExport.Name, t.serviceExport.Namespace, err) } return nil @@ -129,6 +125,7 @@ func (t *targetGroupModelBuildTask) buildModel(ctx context.Context) error { // triggered from service exports/targetgroups func (t *targetGroupModelBuildTask) BuildTargets(ctx context.Context) error { targetTask := &latticeTargetsModelBuildTask{ + log: t.log, client: t.client, tgName: t.serviceExport.Name, tgNamespace: t.serviceExport.Namespace, @@ -137,12 +134,10 @@ func (t *targetGroupModelBuildTask) BuildTargets(ctx context.Context) error { } err := targetTask.buildLatticeTargets(ctx) - if err != nil { - t.log.Infof("Error buildTargets for serviceExport name %v, namespace %v", - t.serviceExport.Name, t.serviceExport.Namespace) return err } + return nil } @@ -151,7 +146,6 @@ func (t *latticeServiceModelBuildTask) buildTargets(ctx context.Context) error { for _, rule := range t.route.Spec().Rules() { for _, backendRef := range rule.BackendRefs() { if string(*backendRef.Kind()) == "ServiceImport" { - t.log.Infof("latticeServiceModelBuildTask: ignore service: %v", backendRef) continue } @@ -166,6 +160,7 @@ func (t *latticeServiceModelBuildTask) buildTargets(ctx context.Context) error { } targetTask := &latticeTargetsModelBuildTask{ + log: t.log, client: t.client, tgName: string(backendRef.Name()), tgNamespace: backendNamespace, @@ -177,9 +172,7 @@ func (t *latticeServiceModelBuildTask) buildTargets(ctx context.Context) error { } err := targetTask.buildLatticeTargets(ctx) - if err != nil { - t.log.Infof("Error buildTargets for backend ref service %v", backendRef) return err } } @@ -196,9 +189,11 @@ func (t *targetGroupModelBuildTask) BuildTargetGroupForServiceExport(ctx context } else { tg, err = t.buildTargetGroupForServiceExportDeletion(ctx, tgName) } + if err != nil { return err } + t.tgByResID[tgName] = tg t.targetGroup = tg return nil @@ -220,6 +215,7 @@ func (t *targetGroupModelBuildTask) buildTargetGroupForServiceExportCreation(ctx if err != nil { return nil, err } + protocol := "HTTP" protocolVersion := vpclattice.TargetGroupProtocolVersionHttp1 var healthCheckConfig *vpclattice.HealthCheckConfig @@ -232,6 +228,7 @@ func (t *targetGroupModelBuildTask) buildTargetGroupForServiceExportCreation(ctx } healthCheckConfig = parseHealthCheckConfig(tgp) } + stackTG := latticemodel.NewTargetGroup(t.stack, targetGroupName, latticemodel.TargetGroupSpec{ Name: targetGroupName, Type: latticemodel.TargetGroupTypeIP, @@ -276,14 +273,15 @@ func (t *targetGroupModelBuildTask) buildTargetGroupForServiceExportDeletion(ctx if err != nil { return nil, fmt.Errorf("%w: targetGroupName: %s", err, targetGroupName) } - t.log.Debugf("TargetGroup cached in datastore: %v", dsTG) + if !dsTG.ByBackendRef { // When handling the serviceExport deletion request while having dsTG.ByBackendRef==false, // That means this target group is not in use anymore, i.e., it is not referenced by latticeService rules(aka http/grpc route rules), // so, it can be deleted. Assign the stackTG.Spec.LatticeID to make target group manager can delete it - t.log.Debugf("BuildingTargetGroup: TG %v is NOT in use anymore and can be deleted", stackTG) + t.log.Debugf("Target group %s is not in use anymore and can be deleted", stackTG.Spec.Name) stackTG.Spec.LatticeID = dsTG.ID } + return stackTG, nil } @@ -293,13 +291,8 @@ func (t *latticeServiceModelBuildTask) buildTargetGroup( client client.Client, ) (*latticemodel.TargetGroup, error) { for _, rule := range t.route.Spec().Rules() { - t.log.Infof("buildTargetGroup: %v", rule) - for _, backendRef := range rule.BackendRefs() { - t.log.Infof("buildTargetGroup -- backendRef %v", backendRef) - tgName := t.buildTargetGroupName(ctx, backendRef) - tgSpec, err := t.buildTargetGroupSpec(ctx, client, backendRef) if err != nil { return nil, fmt.Errorf("buildTargetGroupSpec err %w", err) @@ -330,7 +323,6 @@ func (t *latticeServiceModelBuildTask) buildTargetGroup( } } return nil, nil - } // Now, Only k8sService and serviceImport creation deletion use this function to build TargetGroupSpec, serviceExport does not use this function to create TargetGroupSpec @@ -348,7 +340,7 @@ func (t *latticeServiceModelBuildTask) buildTargetGroupSpec( } backendKind := string(*backendRef.Kind()) - t.log.Infof("buildTargetGroupSpec, kind %s", backendKind) + t.log.Debugf("buildTargetGroupSpec, kind %s", backendKind) var vpc = config.VpcID var eksCluster = "" @@ -372,12 +364,11 @@ func (t *latticeServiceModelBuildTask) buildTargetGroupSpec( serviceImport := &mcs_api.ServiceImport{} if err := client.Get(context.TODO(), namespaceName, serviceImport); err == nil { - t.log.Infof("buildTargetGroupSpec, using service Import %v", namespaceName) + t.log.Debugf("Building target group spec using service import %s", namespaceName) vpc = serviceImport.Annotations["multicluster.x-k8s.io/aws-vpc"] eksCluster = serviceImport.Annotations["multicluster.x-k8s.io/aws-eks-cluster-name"] - } else { - t.log.Infof("buildTargetGroupSpec, using service Import %v, err :%v", namespaceName, err) + t.log.Errorf("Error building target group spec using service import %s due to %s", namespaceName, err) if !isDeleted { //Return error for creation request only. //For ServiceImport deletion request, we should go ahead to build TargetGroupSpec model, @@ -388,10 +379,10 @@ func (t *latticeServiceModelBuildTask) buildTargetGroupSpec( } else { var namespace = t.route.Namespace() - if backendRef.Namespace() != nil { namespace = string(*backendRef.Namespace()) } + // find out service target port serviceNamespaceName := types.NamespacedName{ Namespace: namespace, @@ -400,7 +391,7 @@ func (t *latticeServiceModelBuildTask) buildTargetGroupSpec( svc := &corev1.Service{} if err := t.client.Get(ctx, serviceNamespaceName, svc); err != nil { - t.log.Infof("Error finding backend service %v error :%v", serviceNamespaceName, err) + t.log.Infof("Error finding backend service %s due to %s", serviceNamespaceName, err) if !isDeleted { //Return error for creation request only, //For k8sService deletion request, we should go ahead to build TargetGroupSpec model @@ -505,10 +496,8 @@ func parseHealthCheckConfig(tgp *v1alpha1.TargetGroupPolicy) *vpclattice.HealthC func buildTargetGroupIpAdressType(svc *corev1.Service) (string, error) { ipFamilies := svc.Spec.IPFamilies - glog.V(6).Infof("buildTargetGroupIpAddressType ipFamilies: %v\n", ipFamilies) - if len(ipFamilies) != 1 { - return "", errors.New("Lattice Target Group only support single stack ip addresses") + return "", errors.New("Lattice Target Group only supports single stack IP addresses") } // IpFamilies will always have at least 1 element @@ -520,6 +509,6 @@ func buildTargetGroupIpAdressType(svc *corev1.Service) (string, error) { case corev1.IPv6Protocol: return vpclattice.IpAddressTypeIpv6, nil default: - return "", fmt.Errorf("unknown ipFamily: %v", ipFamily) + return "", fmt.Errorf("unknown ipFamily: %s", ipFamily) } } diff --git a/pkg/gateway/model_build_targets.go b/pkg/gateway/model_build_targets.go index a06a5615..a1dacb8b 100644 --- a/pkg/gateway/model_build_targets.go +++ b/pkg/gateway/model_build_targets.go @@ -7,8 +7,6 @@ import ( "strconv" "strings" - "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -19,6 +17,7 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-application-networking-k8s/pkg/model/core" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) const ( @@ -32,28 +31,36 @@ type LatticeTargetsBuilder interface { } type LatticeTargetsModelBuilder struct { + log gwlog.Logger client client.Client defaultTags map[string]string datastore *latticestore.LatticeDataStore cloud lattice_aws.Cloud } -func NewTargetsBuilder(client client.Client, cloud lattice_aws.Cloud, datastore *latticestore.LatticeDataStore) *LatticeTargetsModelBuilder { +func NewTargetsBuilder( + log gwlog.Logger, + client client.Client, + cloud lattice_aws.Cloud, + datastore *latticestore.LatticeDataStore, +) *LatticeTargetsModelBuilder { return &LatticeTargetsModelBuilder{ + log: log, client: client, cloud: cloud, datastore: datastore, } } -func (b *LatticeTargetsModelBuilder) Build(ctx context.Context, service *corev1.Service, routename string) (core.Stack, *latticemodel.Targets, error) { +func (b *LatticeTargetsModelBuilder) Build(ctx context.Context, service *corev1.Service, routeName string) (core.Stack, *latticemodel.Targets, error) { stack := core.NewDefaultStack(core.StackID(k8s.NamespacedName(service))) task := &latticeTargetsModelBuildTask{ + log: b.log, client: b.client, tgName: service.Name, tgNamespace: service.Namespace, - routeName: routename, + routeName: routeName, stack: stack, datastore: b.datastore, } @@ -67,18 +74,14 @@ func (b *LatticeTargetsModelBuilder) Build(ctx context.Context, service *corev1. func (t *latticeTargetsModelBuildTask) run(ctx context.Context) error { err := t.buildModel(ctx) - return err } func (t *latticeTargetsModelBuildTask) buildModel(ctx context.Context) error { err := t.buildLatticeTargets(ctx) - if err != nil { - glog.V(6).Infof("Failed on buildLatticeTargets %s", err) return err } - return nil } @@ -104,8 +107,7 @@ func (t *latticeTargetsModelBuildTask) buildLatticeTargets(ctx context.Context) } if err := t.client.Get(ctx, namespacedName, svc); err != nil { - errmsg := fmt.Sprintf("Build Targets failed because K8S service %s does not exist", namespacedName) - return errors.New(errmsg) + return fmt.Errorf("Build Targets failed because K8S service %s does not exist", namespacedName) } definedPorts := make(map[int32]struct{}) @@ -114,19 +116,19 @@ func (t *latticeTargetsModelBuildTask) buildLatticeTargets(ctx context.Context) serviceExport := &mcs_api.ServiceExport{} err = t.client.Get(ctx, namespacedName, serviceExport) if err != nil { - glog.V(6).Infof("Failed to find Service export in the DS. Name:%s, Namespace:%s - err:%s", t.tgName, t.tgNamespace, err) + t.log.Errorf("Failed to find service export %s-%s in datastore due to %s", t.tgName, t.tgNamespace, err) } else { portsAnnotations := strings.Split(serviceExport.ObjectMeta.Annotations[portAnnotationsKey], ",") for _, portAnnotation := range portsAnnotations { definedPort, err := strconv.ParseInt(portAnnotation, 10, 32) if err != nil { - glog.V(6).Infof("Failed to read Annotations/Port:%s, err:%s", serviceExport.ObjectMeta.Annotations[portAnnotationsKey], err) + t.log.Errorf("Failed to read Annotations/Port: %s due to %s", + serviceExport.ObjectMeta.Annotations[portAnnotationsKey], err) } else { definedPorts[int32(definedPort)] = struct{}{} } } - glog.V(6).Infof("Build Targets - portAnnotations: %v", definedPorts) } } else if tg.ByBackendRef && t.backendRefPort != undefinedPort { definedPorts[t.backendRefPort] = struct{}{} @@ -163,17 +165,12 @@ func (t *latticeTargetsModelBuildTask) buildLatticeTargets(ctx context.Context) if svc.DeletionTimestamp.IsZero() { if err := t.client.Get(ctx, namespacedName, endpoints); err != nil { - errmsg := fmt.Sprintf("Build Targets failed because K8S service %s does not exist", namespacedName) - glog.V(6).Infof("errmsg: %s", errmsg) - return errors.New(errmsg) + return fmt.Errorf("build targets failed because K8S service %s does not exist", namespacedName) } - glog.V(6).Infof("Build Targets: endpoints %s", endpoints) - for _, endPoint := range endpoints.Subsets { for _, address := range endPoint.Addresses { for _, port := range endPoint.Ports { - glog.V(6).Infof("serviceReconcile-endpoints: address %v, port %v", address, port) target := latticemodel.Target{ TargetIP: address.IP, Port: int64(port.Port), @@ -188,8 +185,6 @@ func (t *latticeTargetsModelBuildTask) buildLatticeTargets(ctx context.Context) } } - glog.V(6).Infof("Build Targets--- targetIPList [%v]", targetList) - spec := latticemodel.TargetsSpec{ Name: t.tgName, Namespace: t.tgNamespace, @@ -203,6 +198,7 @@ func (t *latticeTargetsModelBuildTask) buildLatticeTargets(ctx context.Context) } type latticeTargetsModelBuildTask struct { + log gwlog.Logger client client.Client tgName string tgNamespace string diff --git a/pkg/gateway/model_build_targets_test.go b/pkg/gateway/model_build_targets_test.go index bb93e059..f2796c1a 100644 --- a/pkg/gateway/model_build_targets_test.go +++ b/pkg/gateway/model_build_targets_test.go @@ -21,6 +21,8 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-application-networking-k8s/pkg/model/core" latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "k8s.io/apimachinery/pkg/util/intstr" ) @@ -487,6 +489,7 @@ func Test_Targets(t *testing.T) { Namespace: tt.srvExportNamespace, } targetTask := &latticeTargetsModelBuildTask{ + log: gwlog.FallbackLogger, client: k8sClient, tgName: tt.srvExportName, tgNamespace: tt.srvExportNamespace, diff --git a/pkg/latticestore/introspect.go b/pkg/latticestore/introspect.go index c725c032..1888b3ad 100644 --- a/pkg/latticestore/introspect.go +++ b/pkg/latticestore/introspect.go @@ -1,14 +1,13 @@ package latticestore import ( - "github.com/golang/glog" - "encoding/json" "net" "net/http" "strings" "time" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" "github.com/aws/aws-application-networking-k8s/pkg/utils/retry" ) @@ -27,13 +26,12 @@ type LoggingHandler struct { } func (lh LoggingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - glog.V(6).Infof("Handling http request: %s, from: %s, URI: %s\n", r.Method, r.RemoteAddr, r.RequestURI) + gwlog.FallbackLogger.Debugf("Handling http request: %s, from: %s, URI: %s\n", r.Method, r.RemoteAddr, r.RequestURI) lh.h.ServeHTTP(w, r) } func (c *LatticeDataStore) ServeIntrospection() { - - glog.V(6).Infof("Starting LatticeDataStore serve Introspection\n") + gwlog.FallbackLogger.Debugf("Starting LatticeDataStore serve Introspection\n") server := c.setupIntrospectionServer() for { @@ -70,11 +68,11 @@ func (c *LatticeDataStore) setupIntrospectionServer() *http.Server { availableCommandResponse, err := json.Marshal(&availableCommands) if err != nil { - glog.V(6).Infof("Failed to marshal: %v\n", err) + gwlog.FallbackLogger.Debugf("Failed to marshal: %s", err) } defaultHandler := func(w http.ResponseWriter, r *http.Request) { - glog.V(6).Info(w.Write(availableCommandResponse)) + gwlog.FallbackLogger.Debug(w.Write(availableCommandResponse)) } serveMux := http.NewServeMux() serveMux.HandleFunc("/", defaultHandler) @@ -88,7 +86,7 @@ func (c *LatticeDataStore) setupIntrospectionServer() *http.Server { addr := defaultIntrospectionBindAddress - glog.V(2).Infof("Serving introspection endpoints on %s\n", addr) + gwlog.FallbackLogger.Infof("Serving introspection endpoints on %s", addr) server := &http.Server{ Addr: addr, @@ -101,18 +99,17 @@ func (c *LatticeDataStore) setupIntrospectionServer() *http.Server { func latticecacheHandler(c *LatticeDataStore) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { - store := dumpCurrentLatticeDataStore(c) //TODO responseJSON, err := json.Marshal(store) if err != nil { - glog.V(6).Infof("Failed to marshal latticecache %v\n", err) + gwlog.FallbackLogger.Errorf("Failed to marshal latticecache %s", err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } - glog.V(6).Infof("store :%v \n", store) - glog.V(6).Info(w.Write(responseJSON)) + gwlog.FallbackLogger.Debugf("store :%v", store) + gwlog.FallbackLogger.Debug(w.Write(responseJSON)) } } diff --git a/test/go.mod b/test/go.mod index 45574bda..41bc514b 100644 --- a/test/go.mod +++ b/test/go.mod @@ -17,6 +17,7 @@ require ( k8s.io/apimachinery v0.26.2 k8s.io/client-go v0.26.2 sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/external-dns v0.13.5 sigs.k8s.io/gateway-api v0.6.1 sigs.k8s.io/mcs-api v0.1.0 ) @@ -35,7 +36,6 @@ require ( github.com/go-openapi/swag v0.19.14 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -81,7 +81,6 @@ require ( k8s.io/klog/v2 v2.80.1 // indirect k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect - sigs.k8s.io/external-dns v0.13.5 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/test/go.sum b/test/go.sum index d7b65690..51dc3f16 100644 --- a/test/go.sum +++ b/test/go.sum @@ -213,8 +213,6 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -547,8 +545,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -572,6 +569,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -618,8 +616,7 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -703,14 +700,12 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -721,8 +716,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -781,8 +775,7 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=