From d1781e847d2a953fe76e9d329511d8ea606b591b Mon Sep 17 00:00:00 2001 From: Shawn Kaplan Date: Sat, 23 Sep 2023 22:00:47 -0700 Subject: [PATCH] Logging cleanup for event handlers, listener and rule manager, and listener synthesizer. Added e2e-test and e2e-clean to make help output. --- Makefile | 5 +- controllers/eventhandlers/gateway.go | 22 +- controllers/eventhandlers/gatewayclass.go | 34 +- controllers/gateway_controller.go | 2 +- pkg/deploy/lattice/listener_manager.go | 109 +++---- pkg/deploy/lattice/listener_manager_test.go | 14 +- pkg/deploy/lattice/listener_synthesizer.go | 79 ++--- .../lattice/listener_synthesizer_test.go | 8 +- pkg/deploy/lattice/rule_manager.go | 302 +++++++----------- pkg/deploy/lattice/rule_manager_mock.go | 24 +- pkg/deploy/lattice/rule_manager_test.go | 23 +- pkg/deploy/lattice/rule_synthesizer.go | 13 +- pkg/deploy/lattice/rule_synthesizer_test.go | 6 +- pkg/deploy/stack_deployer.go | 18 +- pkg/deploy/stack_deployer_test.go | 23 +- 15 files changed, 315 insertions(+), 367 deletions(-) diff --git a/Makefile b/Makefile index c732b165..bb9bc05e 100644 --- a/Makefile +++ b/Makefile @@ -96,9 +96,8 @@ manifest: ## Generate CRD manifest e2e-test-namespace := "e2e-test" -## Run e2e tests against cluster pointed to by ~/.kube/config .PHONY: e2e-test -e2e-test: +e2e-test: ## Run e2e tests against cluster pointed to by ~/.kube/config @kubectl create namespace $(e2e-test-namespace) > /dev/null 2>&1 || true # ignore already exists error cd test && go test \ -p 1 \ @@ -112,7 +111,7 @@ e2e-test: .SILENT: .PHONY: e2e-clean -e2e-clean: +e2e-clean: ## Delete eks resources created in the e2e test namespace @echo -n "Cleaning up e2e tests... " @kubectl delete namespace $(e2e-test-namespace) > /dev/null 2>&1 @kubectl create namespace $(e2e-test-namespace) > /dev/null 2>&1 diff --git a/controllers/eventhandlers/gateway.go b/controllers/eventhandlers/gateway.go index c6a7e5b4..7377c0b6 100644 --- a/controllers/eventhandlers/gateway.go +++ b/controllers/eventhandlers/gateway.go @@ -7,8 +7,6 @@ import ( "github.com/aws/aws-application-networking-k8s/pkg/model/core" "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -39,7 +37,8 @@ var ZeroTransitionTime = metav1.NewTime(time.Time{}) func (h *enqueueRequestsForGatewayEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) { gwNew := e.Object.(*gateway_api.Gateway) - glog.V(2).Infof("Gateway Create and Spec is %v", gwNew.Spec) + + h.log.Infof("Received Create event for Gateway %s-%s", gwNew.Name, gwNew.Namespace) // initialize transition time gwNew.Status.Conditions[0].LastTransitionTime = ZeroTransitionTime @@ -47,14 +46,12 @@ func (h *enqueueRequestsForGatewayEvent) Create(e event.CreateEvent, queue workq } func (h *enqueueRequestsForGatewayEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) { - h.log.Info("Gateway Update ") - gwOld := e.ObjectOld.(*gateway_api.Gateway) gwNew := e.ObjectNew.(*gateway_api.Gateway) + h.log.Infof("Received Update event for Gateway %s-%s", gwNew.GetName(), gwNew.GetNamespace()) + if !equality.Semantic.DeepEqual(gwOld.Spec, gwNew.Spec) { - glog.V(2).Infof("Gateway Update old spec %v to new spec %v", - gwOld.Spec, gwNew.Spec) // initialize transition time gwNew.Status.Conditions[0].LastTransitionTime = ZeroTransitionTime h.enqueueImpactedRoutes(queue) @@ -75,10 +72,10 @@ func (h *enqueueRequestsForGatewayEvent) enqueueImpactedRoutes(queue workqueue.R h.log.Errorf("Failed to list all routes, %s", err) return } - for _, route := range routes { + for _, route := range routes { if len(route.Spec().ParentRefs()) <= 0 { - h.log.Infof("Ignore route no parentRefs %s", route.Name()) + h.log.Debugf("Ignoring Route with no parentRef %s-%s", route.Name(), route.Namespace()) continue } @@ -95,7 +92,7 @@ func (h *enqueueRequestsForGatewayEvent) enqueueImpactedRoutes(queue workqueue.R gw := &gateway_api.Gateway{} if err := h.client.Get(context.TODO(), gwName, gw); err != nil { - h.log.Infof("Ignore Route with unknown parentRef %s", route.Name()) + h.log.Debugf("Ignoring Route with unknown parentRef %s-%s", route.Name(), route.Namespace()) continue } @@ -107,12 +104,12 @@ func (h *enqueueRequestsForGatewayEvent) enqueueImpactedRoutes(queue workqueue.R } if err := h.client.Get(context.TODO(), gwClassName, gwClass); err != nil { - h.log.Infof("Ignore Route with unknown Gateway %s", route.Name()) + h.log.Debugf("Ignoring Route with unknown Gateway %s-%s", route.Name(), route.Namespace()) continue } if gwClass.Spec.ControllerName == config.LatticeGatewayControllerName { - glog.V(2).Infof("Trigger Route from Gateway event, route %s", route.Name()) + h.log.Debugf("Adding Route %s-%s to queue due to Gateway event", route.Name(), route.Namespace()) queue.Add(reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: route.Namespace(), @@ -120,6 +117,5 @@ func (h *enqueueRequestsForGatewayEvent) enqueueImpactedRoutes(queue workqueue.R }, }) } - } } diff --git a/controllers/eventhandlers/gatewayclass.go b/controllers/eventhandlers/gatewayclass.go index a0c596af..517b489e 100644 --- a/controllers/eventhandlers/gatewayclass.go +++ b/controllers/eventhandlers/gatewayclass.go @@ -2,7 +2,6 @@ package eventhandlers import ( "context" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" @@ -13,15 +12,18 @@ import ( gateway_api "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/aws/aws-application-networking-k8s/pkg/config" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) -func NewEnqueueRequestsForGatewayClassEvent(client client.Client) handler.EventHandler { +func NewEnqueueRequestsForGatewayClassEvent(log gwlog.Logger, client client.Client) handler.EventHandler { return &enqueueRequestsForGatewayClassEvent{ + log: log, client: client, } } type enqueueRequestsForGatewayClassEvent struct { + log gwlog.Logger client client.Client } @@ -31,40 +33,36 @@ func (h *enqueueRequestsForGatewayClassEvent) Create(e event.CreateEvent, queue } func (h *enqueueRequestsForGatewayClassEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) { - glog.V(6).Info("GatwayClass, Update ") } func (h *enqueueRequestsForGatewayClassEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) { - glog.V(6).Info("GatewayClass, Delete") } func (h *enqueueRequestsForGatewayClassEvent) Generic(e event.GenericEvent, queue workqueue.RateLimitingInterface) { } -func (h *enqueueRequestsForGatewayClassEvent) enqueueImpactedGateway(queue workqueue.RateLimitingInterface, gwclass *gateway_api.GatewayClass) { - +func (h *enqueueRequestsForGatewayClassEvent) enqueueImpactedGateway( + queue workqueue.RateLimitingInterface, + gwClass *gateway_api.GatewayClass, +) { gwList := &gateway_api.GatewayList{} - - h.client.List(context.TODO(), gwList) + err := h.client.List(context.TODO(), gwList) + if err != nil { + h.log.Errorf("Error listing Gateways during GatewayClass event %s", err) + return + } for _, gw := range gwList.Items { - - if string(gw.Spec.GatewayClassName) == string(gwclass.Name) { - - if gwclass.Spec.ControllerName == config.LatticeGatewayControllerName { - glog.V(6).Infof("Found matching gateway, %s\n", gw.Name) - + if string(gw.Spec.GatewayClassName) == gwClass.Name { + if gwClass.Spec.ControllerName == config.LatticeGatewayControllerName { + h.log.Debugf("Found matching gateway, %s-%s", gw.Name, gw.Namespace) queue.Add(reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: gw.Namespace, Name: gw.Name, }, }) - } - } - } - } diff --git a/controllers/gateway_controller.go b/controllers/gateway_controller.go index 5a86d03d..a7eabf96 100644 --- a/controllers/gateway_controller.go +++ b/controllers/gateway_controller.go @@ -90,7 +90,7 @@ func RegisterGatewayController( stackMarshaller: stackMarshaller, } - gwClassEventHandler := eventhandlers.NewEnqueueRequestsForGatewayClassEvent(mgrClient) + gwClassEventHandler := eventhandlers.NewEnqueueRequestsForGatewayClassEvent(log, mgrClient) vpcAssociationPolicyEventHandler := eventhandlers.NewVpcAssociationPolicyEventHandler(log, mgrClient) builder := ctrl.NewControllerManagedBy(mgr). For(&gateway_api.Gateway{}) diff --git a/pkg/deploy/lattice/listener_manager.go b/pkg/deploy/lattice/listener_manager.go index a729333f..9871beac 100644 --- a/pkg/deploy/lattice/listener_manager.go +++ b/pkg/deploy/lattice/listener_manager.go @@ -4,15 +4,17 @@ import ( "context" "errors" "fmt" + "github.com/aws/aws-application-networking-k8s/pkg/aws/services" - "strings" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/golang/glog" + "strings" - "github.com/aws/aws-application-networking-k8s/pkg/utils" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/vpclattice" + "github.com/aws/aws-application-networking-k8s/pkg/utils" + 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" @@ -26,12 +28,18 @@ type ListenerManager interface { } type defaultListenerManager struct { + log gwlog.Logger cloud lattice_aws.Cloud latticeDataStore *latticestore.LatticeDataStore } -func NewListenerManager(cloud lattice_aws.Cloud, latticeDataStore *latticestore.LatticeDataStore) *defaultListenerManager { +func NewListenerManager( + log gwlog.Logger, + cloud lattice_aws.Cloud, + latticeDataStore *latticestore.LatticeDataStore, +) *defaultListenerManager { return &defaultListenerManager{ + log: log, cloud: cloud, latticeDataStore: latticeDataStore, } @@ -49,29 +57,31 @@ func (r *ListenerLSNProvider) LatticeServiceName() string { return utils.LatticeServiceName(r.l.Spec.Name, r.l.Spec.Namespace) } -func (d *defaultListenerManager) Create(ctx context.Context, listener *latticemodel.Listener) (latticemodel.ListenerStatus, error) { - glog.V(6).Infof("Creating listener >>>> %v \n", listener) +func (d *defaultListenerManager) Create( + ctx context.Context, + listener *latticemodel.Listener, +) (latticemodel.ListenerStatus, error) { + listenerSpec := listener.Spec + d.log.Infof("Creating listener %s-%s", listenerSpec.Name, listenerSpec.Namespace) svc, err1 := d.cloud.Lattice().FindService(ctx, &ListenerLSNProvider{listener}) if err1 != nil { if services.IsNotFoundError(err1) { - errMsg := fmt.Sprintf("Service %v not found during listener creation", listener.Spec.Name) - glog.V(6).Infof("Error during create listner %s \n", errMsg) - return latticemodel.ListenerStatus{}, errors.New(errMsg) + errMsg := fmt.Sprintf("Service not found during creation of Listener %s-%s", + listenerSpec.Name, listenerSpec.Namespace) + return latticemodel.ListenerStatus{}, fmt.Errorf(errMsg) } else { return latticemodel.ListenerStatus{}, err1 } } lis, err2 := d.findListenerByNamePort(ctx, *svc.Id, listener.Spec.Port) - glog.V(6).Infof("findListenerByNamePort %v , listener %v error %v\n", listener, lis, err2) - if err2 == nil { // update Listener - k8sname, k8snamespace := latticeName2k8s(aws.StringValue(lis.Name)) + k8sName, k8sNamespace := latticeName2k8s(aws.StringValue(lis.Name)) return latticemodel.ListenerStatus{ - Name: k8sname, - Namespace: k8snamespace, + Name: k8sName, + Namespace: k8sNamespace, Port: aws.Int64Value(lis.Port), Protocol: aws.StringValue(lis.Protocol), ListenerARN: aws.StringValue(lis.Arn), @@ -85,12 +95,12 @@ func (d *defaultListenerManager) Create(ctx context.Context, listener *latticemo defaultResp := vpclattice.FixedResponseAction{ StatusCode: defaultStatus, } + listenerInput := vpclattice.CreateListenerInput{ ClientToken: nil, DefaultAction: &vpclattice.RuleAction{ FixedResponse: &defaultResp, }, - Name: aws.String(k8sLatticeListenerName(listener.Spec.Name, listener.Spec.Namespace, int(listener.Spec.Port), listener.Spec.Protocol)), Port: aws.Int64(listener.Spec.Port), Protocol: aws.String(listener.Spec.Protocol), @@ -99,12 +109,10 @@ func (d *defaultListenerManager) Create(ctx context.Context, listener *latticemo } resp, err := d.cloud.Lattice().CreateListener(&listenerInput) + if err != nil { + d.log.Errorf("Error during creation of Listener %s-%s", listenerSpec.Name, listenerSpec.Namespace) + } - glog.V(2).Infoln("############req creating listner ###########") - glog.V(2).Infoln(listenerInput) - glog.V(2).Infoln("############resp creating listner ###########") - glog.V(2).Infof("create listener err :%v\n", err) - glog.V(2).Infoln(resp) return latticemodel.ListenerStatus{ Name: listener.Spec.Name, Namespace: listener.Spec.Namespace, @@ -112,40 +120,35 @@ func (d *defaultListenerManager) Create(ctx context.Context, listener *latticemo ListenerID: aws.StringValue(resp.Id), ServiceID: aws.StringValue(svc.Id), Port: listener.Spec.Port, - Protocol: listener.Spec.Protocol}, nil + Protocol: listener.Spec.Protocol, + }, nil } func k8sLatticeListenerName(name string, namespace string, port int, protocol string) string { listenerName := fmt.Sprintf("%s-%s-%d-%s", utils.Truncate(name, 20), utils.Truncate(namespace, 18), port, strings.ToLower(protocol)) - return listenerName } func latticeName2k8s(name string) (string, string) { // TODO handle namespace return name, "default" - } func (d *defaultListenerManager) List(ctx context.Context, serviceID string) ([]*vpclattice.ListenerSummary, error) { var sdkListeners []*vpclattice.ListenerSummary - glog.V(6).Infof("List - defaultListenerManager serviceID %v \n", serviceID) + d.log.Debugf("Listing listeners for service %s", serviceID) listenerListInput := vpclattice.ListListenersInput{ ServiceIdentifier: aws.String(serviceID), } resp, err := d.cloud.Lattice().ListListeners(&listenerListInput) - if err != nil { - glog.V(6).Infof("defaultListenerManager: Failed to list service err %v \n", err) return sdkListeners, err } - glog.V(6).Infoln("############resp list listener ###########") - glog.V(6).Infoln(resp) + d.log.Debugf("Found listeners for service %v", resp.Items) for _, r := range resp.Items { - listener := vpclattice.ListenerSummary{ Arn: r.Arn, Id: r.Id, @@ -154,52 +157,42 @@ func (d *defaultListenerManager) List(ctx context.Context, serviceID string) ([] Name: r.Name, } sdkListeners = append(sdkListeners, &listener) - } return sdkListeners, nil - } -func (d *defaultListenerManager) findListenerByNamePort(ctx context.Context, serviceID string, port int64) (*vpclattice.ListenerSummary, error) { - glog.V(6).Infof("calling findListenerByNamePort serviceID %v port %d \n", serviceID, port) +func (d *defaultListenerManager) findListenerByNamePort( + ctx context.Context, + serviceId string, + port int64, +) (*vpclattice.ListenerSummary, error) { listenerListInput := vpclattice.ListListenersInput{ - ServiceIdentifier: aws.String(serviceID), + ServiceIdentifier: aws.String(serviceId), } resp, err := d.cloud.Lattice().ListListenersWithContext(ctx, &listenerListInput) + if err != nil { + return nil, err + } - if err == nil { - for _, r := range resp.Items { - glog.V(6).Infof("findListenerByNamePort>> output port %v item: %v \n", port, r) - if aws.Int64Value(r.Port) == port { - glog.V(6).Infof("Listener %s Port %v already exists arn: %v \n", serviceID, port, r.Arn) - return r, nil - - } - + for _, r := range resp.Items { + if aws.Int64Value(r.Port) == port { + d.log.Debugf("Port %d already in use by listener %s for service %s", port, *r.Arn, serviceId) + return r, nil } - } else { - return nil, err } - return nil, errors.New("Listener does not exist") + return nil, errors.New("listener does not exist") } -func (d *defaultListenerManager) Delete(ctx context.Context, listenerID string, serviceID string) error { - - // TODO - glog.V(6).Infof("listern--Delete >>> listener %v in service %v\n", listenerID, serviceID) +func (d *defaultListenerManager) Delete(ctx context.Context, listenerId string, serviceId string) error { + d.log.Debugf("Deleting listener %s in service %s", listenerId, serviceId) listenerDeleteInput := vpclattice.DeleteListenerInput{ - ServiceIdentifier: aws.String(serviceID), - ListenerIdentifier: aws.String(listenerID), + ServiceIdentifier: aws.String(serviceId), + ListenerIdentifier: aws.String(listenerId), } - resp, err := d.cloud.Lattice().DeleteListener(&listenerDeleteInput) - - glog.V(2).Infoln("############ req delete listner ###########") - glog.V(2).Infoln(listenerDeleteInput) - glog.V(2).Infoln("############resp delete listner ###########") - glog.V(2).Infof("Delete listener resp %vm err :%v\n", resp, err) + _, err := d.cloud.Lattice().DeleteListener(&listenerDeleteInput) return err } diff --git a/pkg/deploy/lattice/listener_manager_test.go b/pkg/deploy/lattice/listener_manager_test.go index 0df89814..e77de96f 100644 --- a/pkg/deploy/lattice/listener_manager_test.go +++ b/pkg/deploy/lattice/listener_manager_test.go @@ -11,16 +11,19 @@ import ( "testing" "github.com/aws/aws-application-networking-k8s/pkg/model/core" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" - "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-sdk-go/service/vpclattice" + "github.com/aws/aws-application-networking-k8s/pkg/latticestore" + mocks_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" mocks "github.com/aws/aws-application-networking-k8s/pkg/aws/services" - latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + + latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" ) var namespaceName = types.NamespacedName{ @@ -109,7 +112,7 @@ func Test_AddListener(t *testing.T) { mockCloud.EXPECT().Lattice().Return(mockLattice).AnyTimes() latticeDataStore := latticestore.NewLatticeDataStore() - listenerManager := NewListenerManager(mockCloud, latticeDataStore) + listenerManager := NewListenerManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) var serviceID = "serviceID" var serviceARN = "serviceARN" @@ -238,7 +241,7 @@ func Test_ListListener(t *testing.T) { mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() latticeDataStore := latticestore.NewLatticeDataStore() - listenerManager := NewListenerManager(mockCloud, latticeDataStore) + listenerManager := NewListenerManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) serviceID := "service1-ID" listenerListInput := vpclattice.ListListenersInput{ @@ -290,8 +293,7 @@ func Test_DeleteListerner(t *testing.T) { mockVpcLatticeSess.EXPECT().DeleteListener(&listenerDeleteInput).Return(&listenerDeleteOuput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - listenerManager := NewListenerManager(mockCloud, latticeDataStore) + listenerManager := NewListenerManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) listenerManager.Delete(ctx, listenerID, serviceID) - } diff --git a/pkg/deploy/lattice/listener_synthesizer.go b/pkg/deploy/lattice/listener_synthesizer.go index eaa01dd8..a26e81fa 100644 --- a/pkg/deploy/lattice/listener_synthesizer.go +++ b/pkg/deploy/lattice/listener_synthesizer.go @@ -4,25 +4,32 @@ import ( "context" "errors" "fmt" - "github.com/golang/glog" //"string" + "github.com/aws/aws-sdk-go/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-sdk-go/aws" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" ) type listenerSynthesizer struct { + log gwlog.Logger listenerMgr ListenerManager stack core.Stack latticestore *latticestore.LatticeDataStore } -func NewListenerSynthesizer(ListenerManager ListenerManager, stack core.Stack, store *latticestore.LatticeDataStore) *listenerSynthesizer { - +func NewListenerSynthesizer( + log gwlog.Logger, + ListenerManager ListenerManager, + stack core.Stack, + store *latticestore.LatticeDataStore, +) *listenerSynthesizer { return &listenerSynthesizer{ + log: log, listenerMgr: ListenerManager, stack: stack, latticestore: store, @@ -32,59 +39,59 @@ func NewListenerSynthesizer(ListenerManager ListenerManager, stack core.Stack, s func (l *listenerSynthesizer) Synthesize(ctx context.Context) error { var resListener []*latticemodel.Listener - l.stack.ListResources(&resListener) - - glog.V(6).Infof("Synthesize Listener: %v\n", resListener) + err := l.stack.ListResources(&resListener) + if err != nil { + l.log.Errorf("Failed to list stack Listeners during Listener synthesis due to err %s", err) + } for _, listener := range resListener { + l.log.Debugf("Attempting to synthesize listener %s-%s", listener.Spec.Name, listener.Spec.Namespace) status, err := l.listenerMgr.Create(ctx, listener) - if err != nil { - errmsg := fmt.Sprintf("ListenerSynthesie: failed to create listener %v, err %v", listener, err) - glog.V(6).Infof("Fail to listenerSynthesizer: %s \n", errmsg) + errmsg := fmt.Sprintf("failed to create listener %s-%s during synthesis due to err %s", + listener.Spec.Name, listener.Spec.Namespace, err) return errors.New(errmsg) } - glog.V(6).Infof("Success synthesize listern %v \n", listener) + l.log.Debugf("Successfully synthesized listener %s-%s", listener.Spec.Name, listener.Spec.Namespace) l.latticestore.AddListener(listener.Spec.Name, listener.Spec.Namespace, listener.Spec.Port, - listener.Spec.Protocol, - status.ListenerARN, status.ListenerID) + listener.Spec.Protocol, status.ListenerARN, status.ListenerID) } // handle delete sdkListeners, err := l.getSDKListeners(ctx) - glog.V(6).Infof("getSDKlistener result: %v, err: %v\n", sdkListeners, err) + if err != nil { + l.log.Errorf("Failed to get SDK Listeners during Listener synthesis due to err %s", err) + } for _, sdkListener := range sdkListeners { _, err := l.findMatchListener(ctx, sdkListener, resListener) - if err == nil { continue } - glog.V(6).Infof("ListenerSynthesize >>>> delete staled sdk listener %v\n", *sdkListener) - l.listenerMgr.Delete(ctx, sdkListener.ListenerID, sdkListener.ServiceID) - k8sname, k8snamespace := latticeName2k8s(sdkListener.Name) + l.log.Debugf("Deleting stale SDK Listener %s-%s", sdkListener.Name, sdkListener.Namespace) + err = l.listenerMgr.Delete(ctx, sdkListener.ListenerID, sdkListener.ServiceID) + if err != nil { + l.log.Errorf("Failed to delete SDK Listener %s", sdkListener.ListenerID) + } - l.latticestore.DelListener(k8sname, k8snamespace, sdkListener.Port, sdkListener.Protocol) + k8sName, k8sNamespace := latticeName2k8s(sdkListener.Name) + l.latticestore.DelListener(k8sName, k8sNamespace, sdkListener.Port, sdkListener.Protocol) } return nil } -func (l *listenerSynthesizer) findMatchListener(ctx context.Context, sdkListener *latticemodel.ListenerStatus, resListener []*latticemodel.Listener) (latticemodel.Listener, error) { - +func (l *listenerSynthesizer) findMatchListener( + ctx context.Context, + sdkListener *latticemodel.ListenerStatus, + resListener []*latticemodel.Listener, +) (latticemodel.Listener, error) { for _, moduleListener := range resListener { - if moduleListener.Spec.Port != sdkListener.Port || - moduleListener.Spec.Protocol != sdkListener.Protocol { - glog.V(6).Infof("findMatchListener: skip due to modelListener %v dismatch sdkListener %v\n", - moduleListener, sdkListener) - continue + if moduleListener.Spec.Port == sdkListener.Port && moduleListener.Spec.Protocol == sdkListener.Protocol { + return *moduleListener, nil } - - glog.V(6).Infof("findMatchListener: found matching moduleListener %v \n", moduleListener) - return *moduleListener, nil - } return latticemodel.Listener{}, errors.New("failed to find matching listener in model") } @@ -95,19 +102,18 @@ func (l *listenerSynthesizer) getSDKListeners(ctx context.Context) ([]*latticemo var resService []*latticemodel.Service err := l.stack.ListResources(&resService) - glog.V(6).Infof("service: %v ignore err: %v \n", resService, err) + l.log.Debugf("Ignoring error when listing services %s", err) for _, service := range resService { latticeService, err := l.listenerMgr.Cloud().Lattice().FindService(ctx, service) if err != nil { - glog.V(6).Infof("failed to find in store, service: %v, err: %v \n", service, err) - return sdkListeners, errors.New("failed to find service in store") + errMessage := fmt.Sprintf("failed to find service in store for service %s-%s due to err %s", + service.Spec.Name, service.Spec.Namespace, err) + return sdkListeners, errors.New(errMessage) } listenerSummaries, err := l.listenerMgr.List(ctx, aws.StringValue(latticeService.Id)) - for _, listenerSummary := range listenerSummaries { - sdkListeners = append(sdkListeners, &latticemodel.ListenerStatus{ Name: aws.StringValue(listenerSummary.Name), ListenerARN: aws.StringValue(listenerSummary.Arn), @@ -117,12 +123,9 @@ func (l *listenerSynthesizer) getSDKListeners(ctx context.Context) ([]*latticemo Protocol: aws.StringValue(listenerSummary.Protocol), }) } - } - glog.V(6).Infof("getSDKListeners result >> %v\n", sdkListeners) return sdkListeners, nil - } func (l *listenerSynthesizer) PostSynthesize(ctx context.Context) error { diff --git a/pkg/deploy/lattice/listener_synthesizer_test.go b/pkg/deploy/lattice/listener_synthesizer_test.go index 45d7dd97..51be7087 100644 --- a/pkg/deploy/lattice/listener_synthesizer_test.go +++ b/pkg/deploy/lattice/listener_synthesizer_test.go @@ -2,8 +2,11 @@ package lattice import ( "context" + "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/aws/services" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + sdk "github.com/aws/aws-sdk-go/aws" //"errors" @@ -169,13 +172,11 @@ func Test_SynthesizeListener(t *testing.T) { ServiceID: tt.serviceID, Port: int64(tt.gwListenerPort), Protocol: tt.gwProtocol}, tt.mgrErr) - } else { mockListenerManager.EXPECT().Delete(ctx, tt.listenerID, tt.serviceID).Return(tt.mgrErr) - } - synthesizer := NewListenerSynthesizer(mockListenerManager, stack, ds) + synthesizer := NewListenerSynthesizer(gwlog.FallbackLogger, mockListenerManager, stack, ds) err := synthesizer.Synthesize(ctx) @@ -191,7 +192,6 @@ func Test_SynthesizeListener(t *testing.T) { assert.Equal(t, listener.Key.Name, tt.httpRoute.Name) assert.Equal(t, listener.Key.Namespace, tt.httpRoute.Namespace) assert.Equal(t, listener.Key.Port, int64(tt.gwListenerPort)) - } else { assert.Nil(t, err) diff --git a/pkg/deploy/lattice/rule_manager.go b/pkg/deploy/lattice/rule_manager.go index e758a876..84cbe082 100644 --- a/pkg/deploy/lattice/rule_manager.go +++ b/pkg/deploy/lattice/rule_manager.go @@ -4,15 +4,18 @@ import ( "context" "errors" "fmt" + "github.com/aws/aws-application-networking-k8s/pkg/utils" - "github.com/golang/glog" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "strings" "github.com/aws/aws-sdk-go/aws" - lattice_aws "github.com/aws/aws-application-networking-k8s/pkg/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" ) @@ -20,19 +23,25 @@ import ( type RuleManager interface { Cloud() lattice_aws.Cloud Create(ctx context.Context, rule *latticemodel.Rule) (latticemodel.RuleStatus, error) - Delete(ctx context.Context, ruleID string, listenerID string, serviceID string) error + Delete(ctx context.Context, ruleId string, listenerId string, serviceId string) error Update(ctx context.Context, rules []*latticemodel.Rule) error - List(ctx context.Context, serviceID string, listenerID string) ([]*latticemodel.RuleStatus, error) - Get(ctx context.Context, serviceID string, listernID string, ruleID string) (*vpclattice.GetRuleOutput, error) + List(ctx context.Context, serviceId string, listenerId string) ([]*latticemodel.RuleStatus, error) + Get(ctx context.Context, serviceId string, listenerId string, ruleId string) (*vpclattice.GetRuleOutput, error) } type defaultRuleManager struct { + log gwlog.Logger cloud lattice_aws.Cloud latticeDataStore *latticestore.LatticeDataStore } -func NewRuleManager(cloud lattice_aws.Cloud, store *latticestore.LatticeDataStore) *defaultRuleManager { +func NewRuleManager( + log gwlog.Logger, + cloud lattice_aws.Cloud, + store *latticestore.LatticeDataStore, +) *defaultRuleManager { return &defaultRuleManager{ + log: log, cloud: cloud, latticeDataStore: store, } @@ -42,23 +51,22 @@ func (r *defaultRuleManager) Cloud() lattice_aws.Cloud { return r.cloud } -type RuleLSNPRovider struct { +type RuleLSNProvider struct { rule *latticemodel.Rule } -func (r *RuleLSNPRovider) LatticeServiceName() string { +func (r *RuleLSNProvider) LatticeServiceName() string { return utils.LatticeServiceName(r.rule.Spec.ServiceName, r.rule.Spec.ServiceNamespace) } -func (r *defaultRuleManager) Get(ctx context.Context, serviceID string, listernID string, ruleID string) (*vpclattice.GetRuleOutput, error) { - getruleInput := vpclattice.GetRuleInput{ - ListenerIdentifier: aws.String(listernID), - ServiceIdentifier: aws.String(serviceID), - RuleIdentifier: aws.String(ruleID), +func (r *defaultRuleManager) Get(ctx context.Context, serviceId string, listenerId string, ruleId string) (*vpclattice.GetRuleOutput, error) { + getRuleInput := vpclattice.GetRuleInput{ + ListenerIdentifier: aws.String(listenerId), + ServiceIdentifier: aws.String(serviceId), + RuleIdentifier: aws.String(ruleId), } - resp, err := r.cloud.Lattice().GetRule(&getruleInput) - + resp, err := r.cloud.Lattice().GetRule(&getRuleInput) return resp, err } @@ -73,132 +81,103 @@ func (r *defaultRuleManager) List(ctx context.Context, service string, listener var resp *vpclattice.ListRulesOutput resp, err := r.cloud.Lattice().ListRules(&ruleListInput) - - glog.V(6).Infoln("############list rules req############") - glog.V(6).Infof("rule: %v , serviceID: %v, listenerID %v \n", resp, service, listener) - - glog.V(6).Infoln("############list rules resp############") - glog.V(6).Infof("resp: %v, err: %v\n", resp, err) - if err != nil { return sdkRules, err } for _, ruleSum := range resp.Items { - if aws.BoolValue(ruleSum.IsDefault) { - continue - } - - sdkRules = append(sdkRules, - &latticemodel.RuleStatus{ + if !aws.BoolValue(ruleSum.IsDefault) { + sdkRules = append(sdkRules, &latticemodel.RuleStatus{ RuleID: aws.StringValue(ruleSum.Id), ServiceID: service, ListenerID: listener, }) + } } + return sdkRules, nil } // today, it only batch update the priority func (r *defaultRuleManager) Update(ctx context.Context, rules []*latticemodel.Rule) error { - + firstRuleSpec := rules[0].Spec var ruleUpdateList []*vpclattice.RuleUpdate - glog.V(6).Infof("Rule --- update >>>>>>>>.%v\n", rules) - - latticeService, err := r.cloud.Lattice().FindService(ctx, &RuleLSNPRovider{rules[0]}) + latticeService, err := r.cloud.Lattice().FindService(ctx, &RuleLSNProvider{rules[0]}) if err != nil { - errmsg := fmt.Sprintf("Service %v not found during rule creation", rules[0].Spec) - glog.V(2).Infof("Error during update rule %s \n", errmsg) - return errors.New(errmsg) + return fmt.Errorf("service %s-%s not found during rule creation", + firstRuleSpec.ServiceName, firstRuleSpec.ServiceNamespace) } - listener, err := r.latticeDataStore.GetlListener(rules[0].Spec.ServiceName, rules[0].Spec.ServiceNamespace, - rules[0].Spec.ListenerPort, rules[0].Spec.ListenerProtocol) + listener, err := r.latticeDataStore.GetlListener(firstRuleSpec.ServiceName, firstRuleSpec.ServiceNamespace, + firstRuleSpec.ListenerPort, firstRuleSpec.ListenerProtocol) if err != nil { - errmsg := fmt.Sprintf("Listener %v not found during rule creation", rules[0].Spec) - glog.V(2).Infof("Error during update rule %s \n", errmsg) - return errors.New(errmsg) + return fmt.Errorf("listener not found during rule creation for service %s-%s, port %d, protocol %s", + firstRuleSpec.ServiceName, firstRuleSpec.ServiceNamespace, firstRuleSpec.ListenerPort, firstRuleSpec.ListenerProtocol) } for _, rule := range rules { priority, _ := ruleID2Priority(rule.Spec.RuleID) - ruleupdate := vpclattice.RuleUpdate{ + ruleUpdate := vpclattice.RuleUpdate{ RuleIdentifier: aws.String(rule.Status.RuleID), Priority: aws.Int64(priority), } - ruleUpdateList = append(ruleUpdateList, &ruleupdate) - + ruleUpdateList = append(ruleUpdateList, &ruleUpdate) } - // batchupdate rules using right priority + + // BatchUpdate rules using right priority batchRuleInput := vpclattice.BatchUpdateRuleInput{ ListenerIdentifier: aws.String(listener.ID), ServiceIdentifier: aws.String(*latticeService.Id), Rules: ruleUpdateList, } - resp, err := r.cloud.Lattice().BatchUpdateRule(&batchRuleInput) - - glog.V(2).Infoln("############req updating rule ###########") - glog.V(2).Infoln(batchRuleInput) - glog.V(2).Infof("############resp updateing rule ###########, err: %v \n", err) - glog.V(2).Infoln(resp) - + _, err = r.cloud.Lattice().BatchUpdateRule(&batchRuleInput) return err } func (r *defaultRuleManager) Create(ctx context.Context, rule *latticemodel.Rule) (latticemodel.RuleStatus, error) { - glog.V(6).Infof("Rule --- Create >>>>>>>>.%v\n", *rule) + r.log.Debugf("Creating rule %s for service %s-%s and listener port %d and protocol %s", + rule.Spec.RuleID, rule.Spec.ServiceName, rule.Spec.ServiceNamespace, + rule.Spec.ListenerPort, rule.Spec.ListenerProtocol) - latticeService, err := r.cloud.Lattice().FindService(ctx, &RuleLSNPRovider{rule}) + latticeService, err := r.cloud.Lattice().FindService(ctx, &RuleLSNProvider{rule}) if err != nil { - errmsg := fmt.Sprintf("Service %v not found during rule creation, err: %v", rule.Spec, err) - glog.V(2).Infof("Error during create rule %s \n", errmsg) - return latticemodel.RuleStatus{}, errors.New(errmsg) + return latticemodel.RuleStatus{}, err } listener, err := r.latticeDataStore.GetlListener(rule.Spec.ServiceName, rule.Spec.ServiceNamespace, rule.Spec.ListenerPort, rule.Spec.ListenerProtocol) - if err != nil { - errmsg := fmt.Sprintf("Listener %v not found during rule creation", rule.Spec) - glog.V(2).Infof("Error during create rule %s \n", errmsg) - return latticemodel.RuleStatus{}, errors.New(errmsg) + return latticemodel.RuleStatus{}, err } priority, err := ruleID2Priority(rule.Spec.RuleID) - glog.V(6).Infof("Convert rule id %s to priority %d error: %v \n", rule.Spec.RuleID, priority, err) - if err != nil { - glog.V(2).Infof("Error create rule, failed to convert RuleID %v to priority err :%v\n", rule.Spec.RuleID, err) - return latticemodel.RuleStatus{}, errors.New("failed to create rule, due to invalid ruleID") + return latticemodel.RuleStatus{}, fmt.Errorf("failed to create rule due to invalid ruleId, err: %s", err) } + r.log.Debugf("Converted rule id %s to priority %d", rule.Spec.RuleID, priority) ruleStatus, err := r.findMatchingRule(ctx, rule, *latticeService.Id, listener.ID) - if err == nil && !ruleStatus.UpdateTGsNeeded { - if ruleStatus.Priority != priority { - glog.V(6).Infof("Rule-Create: need to BatchUpdate priority") + r.log.Debugf("Need to BatchUpdate priority for rule %s", rule.Spec.RuleID) ruleStatus.UpdatePriorityNeeded = true } - glog.V(6).Infof("Rule--Create, found existing matching rule %v rulsStatus %v\n", rule, ruleStatus) return ruleStatus, nil } // if not found, ruleStatus contains the next available priority - latticeTGs := []*vpclattice.WeightedTargetGroup{} + var latticeTGs []*vpclattice.WeightedTargetGroup for _, tgRule := range rule.Spec.Action.TargetGroups { - tgName := latticestore.TargetGroupName(tgRule.Name, tgRule.Namespace) - tg, err := r.latticeDataStore.GetTargetGroup(tgName, tgRule.RouteName, tgRule.IsServiceImport) + tg, err := r.latticeDataStore.GetTargetGroup(tgName, tgRule.RouteName, tgRule.IsServiceImport) if err != nil { - glog.V(2).Infof("Faild to create rule due to unknown tg %v, err %v\n", tgName, err) return latticemodel.RuleStatus{}, err } @@ -208,7 +187,6 @@ func (r *defaultRuleManager) Create(ctx context.Context, rule *latticemodel.Rule } latticeTGs = append(latticeTGs, &latticeTG) - } ruleName := fmt.Sprintf("k8s-%d-%s", rule.Spec.CreateTime.Unix(), rule.Spec.RuleID) @@ -234,64 +212,53 @@ func (r *defaultRuleManager) Create(ctx context.Context, rule *latticemodel.Rule } resp, err := r.cloud.Lattice().UpdateRule(&updateRuleInput) + if err != nil { + r.log.Errorf("Error updating rule, %s", err) + } - glog.V(2).Infoln("############req updating rule TGs###########") - glog.V(2).Infoln(updateRuleInput) - glog.V(2).Infof("############resp updating rule TGs ###########, err: %v \n", err) - glog.V(2).Infoln(resp) return latticemodel.RuleStatus{ RuleID: aws.StringValue(resp.Id), UpdatePriorityNeeded: ruleStatus.UpdatePriorityNeeded, ServiceID: aws.StringValue(latticeService.Id), ListenerID: listener.ID, }, nil + } - } else { - - httpMatch := vpclattice.HttpMatch{} + httpMatch := vpclattice.HttpMatch{} - updateSDKhttpMatch(&httpMatch, rule) + updateSDKhttpMatch(&httpMatch, rule) - ruleInput := vpclattice.CreateRuleInput{ - Action: &vpclattice.RuleAction{ - Forward: &vpclattice.ForwardAction{ - TargetGroups: latticeTGs, - }, - }, - ClientToken: nil, - ListenerIdentifier: aws.String(listener.ID), - Match: &vpclattice.RuleMatch{ - HttpMatch: &httpMatch, + ruleInput := vpclattice.CreateRuleInput{ + Action: &vpclattice.RuleAction{ + Forward: &vpclattice.ForwardAction{ + TargetGroups: latticeTGs, }, - Name: aws.String(ruleName), - Priority: aws.Int64(ruleStatus.Priority), - ServiceIdentifier: aws.String(*latticeService.Id), - } - - resp, err := r.cloud.Lattice().CreateRule(&ruleInput) + }, + ClientToken: nil, + ListenerIdentifier: aws.String(listener.ID), + Match: &vpclattice.RuleMatch{ + HttpMatch: &httpMatch, + }, + Name: aws.String(ruleName), + Priority: aws.Int64(ruleStatus.Priority), + ServiceIdentifier: aws.String(*latticeService.Id), + } - glog.V(2).Infoln("############req creating rule ###########") - glog.V(2).Infoln(ruleInput) - glog.V(2).Infof("############resp creating rule ###########, err: %v \n", err) - glog.V(2).Infoln(resp) - if err != nil { - return latticemodel.RuleStatus{}, err - } else { - return latticemodel.RuleStatus{ - RuleID: *resp.Id, - ListenerID: listener.ID, - ServiceID: aws.StringValue(latticeService.Id), - UpdatePriorityNeeded: ruleStatus.UpdatePriorityNeeded, - UpdateTGsNeeded: ruleStatus.UpdatePriorityNeeded, - }, nil - } + resp, err := r.cloud.Lattice().CreateRule(&ruleInput) + if err != nil { + return latticemodel.RuleStatus{}, err } + return latticemodel.RuleStatus{ + RuleID: *resp.Id, + ListenerID: listener.ID, + ServiceID: aws.StringValue(latticeService.Id), + UpdatePriorityNeeded: ruleStatus.UpdatePriorityNeeded, + UpdateTGsNeeded: ruleStatus.UpdatePriorityNeeded, + }, nil } func updateSDKhttpMatch(httpMatch *vpclattice.HttpMatch, rule *latticemodel.Rule) { - glog.V(6).Infof("Setting sdk HttpMatch using rule.Spec %v", rule.Spec) - // setup path based if rule.Spec.PathMatchExact || rule.Spec.PathMatchPrefix { matchType := vpclattice.PathMatchType{} @@ -310,7 +277,6 @@ func updateSDKhttpMatch(httpMatch *vpclattice.HttpMatch, rule *latticemodel.Rule httpMatch.Method = &rule.Spec.Method if rule.Spec.NumOfHeaderMatches > 0 { - for i := 0; i < rule.Spec.NumOfHeaderMatches; i++ { headerMatch := vpclattice.HeaderMatch{ Match: rule.Spec.MatchedHeaders[i].Match, @@ -321,20 +287,18 @@ func updateSDKhttpMatch(httpMatch *vpclattice.HttpMatch, rule *latticemodel.Rule } } -func isRulesSame(modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRuleOutput) bool { +func isRulesSame(log gwlog.Logger, modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRuleOutput) bool { // Exact Path Match if modelRule.Spec.PathMatchExact { - glog.V(6).Infoln("Checking PathMatchExact") - if sdkRuleDetail.Match.HttpMatch.PathMatch == nil || sdkRuleDetail.Match.HttpMatch.PathMatch.Match == nil || sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Exact == nil { - glog.V(6).Infoln("no sdk PathMatchExact match") + log.Debugf("no sdk PathMatchExact match") return false } if aws.StringValue(sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Exact) != modelRule.Spec.PathMatchValue { - glog.V(6).Infoln("Match.Exact mismatch") + log.Debugf("Match.Exact mismatch") return false } @@ -342,46 +306,43 @@ func isRulesSame(modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRule if sdkRuleDetail.Match.HttpMatch.PathMatch != nil && sdkRuleDetail.Match.HttpMatch.PathMatch.Match != nil && sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Exact != nil { - glog.V(6).Infoln("no sdk PathMatchExact match") + log.Debugf("no sdk PathMatchExact match") return false } } // Path Prefix if modelRule.Spec.PathMatchPrefix { - glog.V(6).Infoln("Checking PathMatchPrefix") - if sdkRuleDetail.Match.HttpMatch.PathMatch == nil || sdkRuleDetail.Match.HttpMatch.PathMatch.Match == nil || sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Prefix == nil { - glog.V(6).Infoln("no sdk HTTP PathPrefix") + log.Debugf("no sdk HTTP PathPrefix") return false } if aws.StringValue(sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Prefix) != modelRule.Spec.PathMatchValue { - glog.V(6).Infoln("PathMatchPrefix mismatch ") + log.Debugf("PathMatchPrefix mismatch ") return false } } else { if sdkRuleDetail.Match.HttpMatch.PathMatch != nil && sdkRuleDetail.Match.HttpMatch.PathMatch.Match != nil && sdkRuleDetail.Match.HttpMatch.PathMatch.Match.Prefix != nil { - glog.V(6).Infoln("no sdk HTTP PathPrefix") + log.Debugf("no sdk HTTP PathPrefix") return false } } // Method match if aws.StringValue(sdkRuleDetail.Match.HttpMatch.Method) != modelRule.Spec.Method { - glog.V(6).Infof("Method mismatch '%v' != '%v'\n", modelRule.Spec.Method, sdkRuleDetail.Match.HttpMatch.Method) + log.Debugf("Method mismatch '%s' != '%s'", modelRule.Spec.Method, *sdkRuleDetail.Match.HttpMatch.Method) return false } // Header Match if modelRule.Spec.NumOfHeaderMatches > 0 { - glog.V(6).Infof("Checking Header Match, numofheader matches %v \n", modelRule.Spec.NumOfHeaderMatches) if len(sdkRuleDetail.Match.HttpMatch.HeaderMatches) != modelRule.Spec.NumOfHeaderMatches { - glog.V(6).Infoln("header match number mismatch") + log.Debugf("header match number mismatch") return false } @@ -389,7 +350,6 @@ func isRulesSame(modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRule // compare 2 array for _, sdkHeader := range sdkRuleDetail.Match.HttpMatch.HeaderMatches { - glog.V(6).Infof("sdkHeader >> %v\n", sdkHeader) matchFound := false // check if this is in module for i := 0; i < modelRule.Spec.NumOfHeaderMatches; i++ { @@ -406,13 +366,13 @@ func isRulesSame(modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRule if !matchFound { misMatch = true - glog.V(6).Infof("header not found sdkHeader %v\n", *sdkHeader) + log.Debugf("header %s not found", *sdkHeader) break } } if misMatch { - glog.V(6).Infof("mismatch header") + log.Debugf("mismatch header") return false } } @@ -422,9 +382,12 @@ func isRulesSame(modelRule *latticemodel.Rule, sdkRuleDetail *vpclattice.GetRule // Determine if rule spec is same // If rule spec is same, then determine if there is any changes on target groups -func (r *defaultRuleManager) findMatchingRule(ctx context.Context, rule *latticemodel.Rule, - serviceID string, listenerID string) (latticemodel.RuleStatus, error) { - +func (r *defaultRuleManager) findMatchingRule( + ctx context.Context, + rule *latticemodel.Rule, + serviceId string, + listenerId string, +) (latticemodel.RuleStatus, error) { var priorityMap [100]bool for i := 1; i < 100; i++ { @@ -433,86 +396,73 @@ func (r *defaultRuleManager) findMatchingRule(ctx context.Context, rule *lattice } ruleListInput := vpclattice.ListRulesInput{ - ListenerIdentifier: aws.String(listenerID), - ServiceIdentifier: aws.String(serviceID), + ListenerIdentifier: aws.String(listenerId), + ServiceIdentifier: aws.String(serviceId), } var resp *vpclattice.ListRulesOutput resp, err := r.cloud.Lattice().ListRules(&ruleListInput) - - glog.V(6).Infoln("############list rules req############") - glog.V(6).Infof("rule: %v , serviceID: %v, listenerID %v \n", rule, serviceID, listenerID) - - glog.V(6).Infoln("############list rules resp############") - glog.V(6).Infof("resp: %v, err: %v\n", resp, err) - if err != nil { return latticemodel.RuleStatus{}, err } var matchRule *vpclattice.GetRuleOutput = nil - var updateTGsNeeded bool = false + var updateTGsNeeded = false for _, ruleSum := range resp.Items { - if aws.BoolValue(ruleSum.IsDefault) { // Ignore the default - glog.V(6).Infof("findMatchingRule: ingnore the default rule %v\n", ruleSum) continue } // retrieve action ruleInput := vpclattice.GetRuleInput{ - ListenerIdentifier: &listenerID, - ServiceIdentifier: &serviceID, + ListenerIdentifier: &listenerId, + ServiceIdentifier: &serviceId, RuleIdentifier: ruleSum.Id, } var ruleResp *vpclattice.GetRuleOutput ruleResp, err := r.cloud.Lattice().GetRule(&ruleInput) - if err != nil { - glog.V(2).Infof("findMatchingRule, rule %v not found err:%v\n", ruleInput, err) + r.log.Debugf("Matching rule not found, err %s", err) continue } priorityMap[aws.Int64Value(ruleResp.Priority)] = true - samerule := isRulesSame(rule, ruleResp) - - if !samerule { + ruleIsSame := isRulesSame(r.log, rule, ruleResp) + if !ruleIsSame { continue } matchRule = ruleResp if len(ruleResp.Action.Forward.TargetGroups) != len(rule.Spec.Action.TargetGroups) { - glog.V(6).Infof("Mismatched TGs lattice %v, k8s %v\n", - ruleResp.Action.Forward.TargetGroups, rule.Spec.Action.TargetGroups) + r.log.Debugf("Skipping rule due to mismatched number of target groups to forward to") updateTGsNeeded = true continue } if len(ruleResp.Action.Forward.TargetGroups) == 0 { - glog.V(6).Infof("0 targetGroups \n") + r.log.Debugf("Skipping rule due to 0 targetGroups to forward to") continue } for _, tg := range ruleResp.Action.Forward.TargetGroups { - for _, k8sTG := range rule.Spec.Action.TargetGroups { // get k8sTG id tgName := latticestore.TargetGroupName(k8sTG.Name, k8sTG.Namespace) k8sTGinStore, err := r.latticeDataStore.GetTargetGroup(tgName, rule.Spec.ServiceName, k8sTG.IsServiceImport) if err != nil { - glog.V(6).Infof("Failed to find k8s tg %v in store \n", k8sTG) + r.log.Debugf("Failed to find k8s tg %s-%s in datastore", k8sTG.Name, k8sTG.Namespace) updateTGsNeeded = true continue } if aws.StringValue(tg.TargetGroupIdentifier) != k8sTGinStore.ID { - glog.V(6).Infof("TGID mismatch lattice %v, k8s %v\n", + r.log.Debugf("target group id mismatch in datastore, %s vs. %s", aws.StringValue(tg.TargetGroupIdentifier), k8sTGinStore.ID) updateTGsNeeded = true continue @@ -520,24 +470,19 @@ func (r *defaultRuleManager) findMatchingRule(ctx context.Context, rule *lattice } if k8sTG.Weight != aws.Int64Value(tg.Weight) { - glog.V(6).Infof("Weight has changed for tg %v old %v new %v\n", - tg, aws.Int64Value(tg.Weight), k8sTG.Weight) + r.log.Debugf("Weight has changed for tg %s, old %d vs. new %d", + aws.StringValue(tg.TargetGroupIdentifier), aws.Int64Value(tg.Weight), k8sTG.Weight) updateTGsNeeded = true continue } break - } if updateTGsNeeded { - glog.V(6).Infof("update TGs Needed for tg %v \n", tg) break - } - } - } if matchRule != nil { @@ -546,7 +491,6 @@ func (r *defaultRuleManager) findMatchingRule(ctx context.Context, rule *lattice UpdatePriority := false if inputRulePriority != aws.Int64Value(matchRule.Priority) { UpdatePriority = true - } return latticemodel.RuleStatus{ @@ -568,30 +512,24 @@ func (r *defaultRuleManager) findMatchingRule(ctx context.Context, rule *lattice } return latticemodel.RuleStatus{Priority: nextPriority}, errors.New("rule not found") } - } -func ruleID2Priority(ruleID string) (int64, error) { - +func ruleID2Priority(ruleId string) (int64, error) { var priority int - ruleIDName := strings.NewReader(ruleID) + ruleIDName := strings.NewReader(ruleId) _, err := fmt.Fscanf(ruleIDName, "rule-%d", &priority) - return int64(priority), err } -func (r *defaultRuleManager) Delete(ctx context.Context, ruleID string, listenerID string, serviceID string) error { - glog.V(6).Infof("Rule --- Delete >>>>> rule %v, listener %v service %v \n", ruleID, listenerID, serviceID) +func (r *defaultRuleManager) Delete(ctx context.Context, ruleId string, listenerId string, serviceId string) error { + r.log.Debugf("Deleting rule %s for listener %s and service %s", ruleId, listenerId, serviceId) deleteInput := vpclattice.DeleteRuleInput{ - RuleIdentifier: aws.String(ruleID), - ListenerIdentifier: aws.String(listenerID), - ServiceIdentifier: aws.String(serviceID), + RuleIdentifier: aws.String(ruleId), + ListenerIdentifier: aws.String(listenerId), + ServiceIdentifier: aws.String(serviceId), } - resp, err := r.cloud.Lattice().DeleteRule(&deleteInput) - - glog.V(2).Infof("Delete Rule >>>> input %v, output %v, err %v\n", deleteInput, resp, err) - + _, err := r.cloud.Lattice().DeleteRule(&deleteInput) return err } diff --git a/pkg/deploy/lattice/rule_manager_mock.go b/pkg/deploy/lattice/rule_manager_mock.go index 70a0a3eb..d1d12ffc 100644 --- a/pkg/deploy/lattice/rule_manager_mock.go +++ b/pkg/deploy/lattice/rule_manager_mock.go @@ -67,47 +67,47 @@ func (mr *MockRuleManagerMockRecorder) Create(ctx, rule interface{}) *gomock.Cal } // Delete mocks base method. -func (m *MockRuleManager) Delete(ctx context.Context, ruleID, listenerID, serviceID string) error { +func (m *MockRuleManager) Delete(ctx context.Context, ruleId, listenerId, serviceId string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", ctx, ruleID, listenerID, serviceID) + ret := m.ctrl.Call(m, "Delete", ctx, ruleId, listenerId, serviceId) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockRuleManagerMockRecorder) Delete(ctx, ruleID, listenerID, serviceID interface{}) *gomock.Call { +func (mr *MockRuleManagerMockRecorder) Delete(ctx, ruleId, listenerId, serviceId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRuleManager)(nil).Delete), ctx, ruleID, listenerID, serviceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRuleManager)(nil).Delete), ctx, ruleId, listenerId, serviceId) } // Get mocks base method. -func (m *MockRuleManager) Get(ctx context.Context, serviceID, listernID, ruleID string) (*vpclattice.GetRuleOutput, error) { +func (m *MockRuleManager) Get(ctx context.Context, serviceId, listenerId, ruleId string) (*vpclattice.GetRuleOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, serviceID, listernID, ruleID) + ret := m.ctrl.Call(m, "Get", ctx, serviceId, listenerId, ruleId) ret0, _ := ret[0].(*vpclattice.GetRuleOutput) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRuleManagerMockRecorder) Get(ctx, serviceID, listernID, ruleID interface{}) *gomock.Call { +func (mr *MockRuleManagerMockRecorder) Get(ctx, serviceId, listenerId, ruleId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRuleManager)(nil).Get), ctx, serviceID, listernID, ruleID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRuleManager)(nil).Get), ctx, serviceId, listenerId, ruleId) } // List mocks base method. -func (m *MockRuleManager) List(ctx context.Context, serviceID, listenerID string) ([]*lattice.RuleStatus, error) { +func (m *MockRuleManager) List(ctx context.Context, serviceId, listenerId string) ([]*lattice.RuleStatus, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "List", ctx, serviceID, listenerID) + ret := m.ctrl.Call(m, "List", ctx, serviceId, listenerId) ret0, _ := ret[0].([]*lattice.RuleStatus) ret1, _ := ret[1].(error) return ret0, ret1 } // List indicates an expected call of List. -func (mr *MockRuleManagerMockRecorder) List(ctx, serviceID, listenerID interface{}) *gomock.Call { +func (mr *MockRuleManagerMockRecorder) List(ctx, serviceId, listenerId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRuleManager)(nil).List), ctx, serviceID, listenerID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRuleManager)(nil).List), ctx, serviceId, listenerId) } // Update mocks base method. diff --git a/pkg/deploy/lattice/rule_manager_test.go b/pkg/deploy/lattice/rule_manager_test.go index c579298e..a48a1507 100644 --- a/pkg/deploy/lattice/rule_manager_test.go +++ b/pkg/deploy/lattice/rule_manager_test.go @@ -8,15 +8,18 @@ import ( "testing" - "github.com/aws/aws-application-networking-k8s/pkg/latticestore" "github.com/aws/aws-sdk-go/service/vpclattice" + "github.com/aws/aws-application-networking-k8s/pkg/latticestore" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + mocks_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" mocks "github.com/aws/aws-application-networking-k8s/pkg/aws/services" - latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + + latticemodel "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" ) var rulelist = []struct { @@ -530,12 +533,12 @@ func Test_CreateRule(t *testing.T) { latticeDataStore := latticestore.NewLatticeDataStore() - ruleManager := NewRuleManager(mockCloud, latticeDataStore) + ruleManager := NewRuleManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) if !tt.noServiceID { mockLattice.EXPECT().FindService(gomock.Any(), gomock.Any()).Return( &vpclattice.ServiceSummary{ - Name: aws.String((&RuleLSNPRovider{tt.newRule}).LatticeServiceName()), + Name: aws.String((&RuleLSNProvider{tt.newRule}).LatticeServiceName()), Arn: aws.String("serviceARN"), Id: aws.String(tt.newRule.Status.ServiceID), DnsEntry: &vpclattice.DnsEntry{ @@ -755,13 +758,13 @@ func Test_UpdateRule(t *testing.T) { latticeDataStore := latticestore.NewLatticeDataStore() - ruleManager := NewRuleManager(mockCloud, latticeDataStore) + ruleManager := NewRuleManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) var i = 0 if !tt.noServiceID { mockLattice.EXPECT().FindService(gomock.Any(), gomock.Any()).Return( &vpclattice.ServiceSummary{ - Name: aws.String((&RuleLSNPRovider{rules[i]}).LatticeServiceName()), + Name: aws.String((&RuleLSNProvider{rules[i]}).LatticeServiceName()), Arn: aws.String("serviceARN"), Id: aws.String(rules[i].Status.ServiceID), DnsEntry: &vpclattice.DnsEntry{ @@ -850,7 +853,7 @@ func Test_List(t *testing.T) { mockVpcLatticeSess.EXPECT().ListRules(&ruleInput).Return(&ruleOutput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - ruleManager := NewRuleManager(mockCloud, latticeDataStore) + ruleManager := NewRuleManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) resp, err := ruleManager.List(ctx, serviceID, listenerID) @@ -897,7 +900,7 @@ func Test_GetRule(t *testing.T) { mockVpcLatticeSess.EXPECT().GetRule(&ruleGetInput).Return(&ruleGetOutput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - ruleManager := NewRuleManager(mockCloud, latticeDataStore) + ruleManager := NewRuleManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) resp, err := ruleManager.Get(ctx, serviceID, listenerID, ruleID) @@ -933,7 +936,7 @@ func Test_DeleteRule(t *testing.T) { mockVpcLatticeSess.EXPECT().DeleteRule(&ruleDeleteInput).Return(&ruleDeleteOuput, nil) mockCloud.EXPECT().Lattice().Return(mockVpcLatticeSess).AnyTimes() - ruleManager := NewRuleManager(mockCloud, latticeDataStore) + ruleManager := NewRuleManager(gwlog.FallbackLogger, mockCloud, latticeDataStore) ruleManager.Delete(ctx, ruleID, listenerID, serviceID) @@ -1503,7 +1506,7 @@ func Test_isRulesSame(t *testing.T) { for _, tt := range tests { fmt.Printf("Testing >>>>> %v \n", tt.name) - sameRule := isRulesSame(tt.k8sRule, tt.sdkRule) + sameRule := isRulesSame(gwlog.FallbackLogger, tt.k8sRule, tt.sdkRule) if tt.ruleMatched { assert.True(t, sameRule) diff --git a/pkg/deploy/lattice/rule_synthesizer.go b/pkg/deploy/lattice/rule_synthesizer.go index f9ee6ecd..5ab62052 100644 --- a/pkg/deploy/lattice/rule_synthesizer.go +++ b/pkg/deploy/lattice/rule_synthesizer.go @@ -3,22 +3,31 @@ package lattice import ( "context" "errors" + "github.com/aws/aws-sdk-go/aws" "github.com/golang/glog" "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" ) type ruleSynthesizer struct { + log gwlog.Logger rule RuleManager stack core.Stack latticestore *latticestore.LatticeDataStore } -func NewRuleSynthesizer(ruleManager RuleManager, stack core.Stack, store *latticestore.LatticeDataStore) *ruleSynthesizer { +func NewRuleSynthesizer( + log gwlog.Logger, + ruleManager RuleManager, + stack core.Stack, + store *latticestore.LatticeDataStore, +) *ruleSynthesizer { return &ruleSynthesizer{ + log: log, rule: ruleManager, stack: stack, latticestore: store, @@ -92,7 +101,7 @@ func (r *ruleSynthesizer) findMatchedRule(ctx context.Context, sdkRuleID string, } for _, modelRule := range resRule { - sameRule := isRulesSame(modelRule, sdkRuleDetail) + sameRule := isRulesSame(r.log, modelRule, sdkRuleDetail) if !sameRule { continue diff --git a/pkg/deploy/lattice/rule_synthesizer_test.go b/pkg/deploy/lattice/rule_synthesizer_test.go index 84116acf..003a893b 100644 --- a/pkg/deploy/lattice/rule_synthesizer_test.go +++ b/pkg/deploy/lattice/rule_synthesizer_test.go @@ -2,8 +2,10 @@ package lattice import ( "context" + "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/aws/services" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" //"errors" "fmt" @@ -278,7 +280,7 @@ func Test_SynthesizeRule(t *testing.T) { mockRuleManager.EXPECT().Update(ctx, gomock.Any()) } - synthesizer := NewRuleSynthesizer(mockRuleManager, stack, ds) + synthesizer := NewRuleSynthesizer(gwlog.FallbackLogger, mockRuleManager, stack, ds) err := synthesizer.Synthesize(ctx) @@ -405,7 +407,7 @@ func Test_SynthesizeDeleteRule(t *testing.T) { } - synthesizer := NewRuleSynthesizer(mockRuleManager, stack, ds) + synthesizer := NewRuleSynthesizer(gwlog.FallbackLogger, mockRuleManager, stack, ds) synthesizer.Synthesize(ctx) diff --git a/pkg/deploy/stack_deployer.go b/pkg/deploy/stack_deployer.go index 836b8294..7f30bec2 100644 --- a/pkg/deploy/stack_deployer.go +++ b/pkg/deploy/stack_deployer.go @@ -2,15 +2,17 @@ package deploy import ( "context" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/deploy/externaldns" "github.com/aws/aws-application-networking-k8s/pkg/deploy/lattice" "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" - "sigs.k8s.io/controller-runtime/pkg/client" ) // StackDeployer will deploy a resource stack into AWS and K8S. @@ -71,7 +73,7 @@ func (d *serviceNetworkStackDeployer) Deploy(ctx context.Context, stack core.Sta type LatticeServiceStackDeployer struct { log gwlog.Logger cloud aws.Cloud - k8sclient client.Client + k8sClient client.Client latticeServiceManager lattice.ServiceManager targetGroupManager lattice.TargetGroupManager targetsManager lattice.TargetsManager @@ -90,23 +92,23 @@ func NewLatticeServiceStackDeploy( return &LatticeServiceStackDeployer{ log: log, cloud: cloud, - k8sclient: k8sClient, + k8sClient: k8sClient, latticeServiceManager: lattice.NewServiceManager(cloud, latticeDataStore), targetGroupManager: lattice.NewTargetGroupManager(cloud), targetsManager: lattice.NewTargetsManager(cloud, latticeDataStore), - listenerManager: lattice.NewListenerManager(cloud, latticeDataStore), - ruleManager: lattice.NewRuleManager(cloud, latticeDataStore), + listenerManager: lattice.NewListenerManager(log, cloud, latticeDataStore), + ruleManager: lattice.NewRuleManager(log, cloud, latticeDataStore), dnsEndpointManager: externaldns.NewDnsEndpointManager(k8sClient), latticeDataStore: latticeDataStore, } } 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) + targetGroupSynthesizer := lattice.NewTargetGroupSynthesizer(d.log, d.cloud, d.k8sClient, d.targetGroupManager, stack, d.latticeDataStore) targetsSynthesizer := lattice.NewTargetsSynthesizer(d.cloud, d.targetsManager, stack, d.latticeDataStore) serviceSynthesizer := lattice.NewServiceSynthesizer(d.latticeServiceManager, d.dnsEndpointManager, stack, d.latticeDataStore) - listenerSynthesizer := lattice.NewListenerSynthesizer(d.listenerManager, stack, d.latticeDataStore) - ruleSynthesizer := lattice.NewRuleSynthesizer(d.ruleManager, stack, d.latticeDataStore) + listenerSynthesizer := lattice.NewListenerSynthesizer(d.log, d.listenerManager, stack, d.latticeDataStore) + ruleSynthesizer := lattice.NewRuleSynthesizer(d.log, d.ruleManager, stack, d.latticeDataStore) //Handle targetGroups creation request if err := targetGroupSynthesizer.SynthesizeTriggeredTargetGroupsCreation(ctx); err != nil { diff --git a/pkg/deploy/stack_deployer_test.go b/pkg/deploy/stack_deployer_test.go index b5097ec2..55f8458a 100644 --- a/pkg/deploy/stack_deployer_test.go +++ b/pkg/deploy/stack_deployer_test.go @@ -2,19 +2,22 @@ package deploy import ( "context" - "github.com/aws/aws-application-networking-k8s/pkg/aws/services" - "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/vpclattice" - "testing" + + "github.com/aws/aws-application-networking-k8s/pkg/aws/services" + "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "k8s.io/apimachinery/pkg/types" mock_client "github.com/aws/aws-application-networking-k8s/mocks/controller-runtime/client" mocks_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" "github.com/aws/aws-application-networking-k8s/pkg/deploy/lattice" "github.com/aws/aws-application-networking-k8s/pkg/latticestore" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/assert" - "k8s.io/apimachinery/pkg/types" "github.com/aws/aws-application-networking-k8s/pkg/deploy/externaldns" "github.com/aws/aws-application-networking-k8s/pkg/model/core" @@ -69,7 +72,7 @@ func Test_latticeServiceStackDeployer_createAllResources(t *testing.T) { deployer := &LatticeServiceStackDeployer{ log: gwlog.FallbackLogger, cloud: mockCloud, - k8sclient: mockClient, + k8sClient: mockClient, latticeServiceManager: mockServiceManager, targetGroupManager: mockTargetGroupManager, listenerManager: mockListenerManager, @@ -124,7 +127,7 @@ func Test_latticeServiceStackDeployer_CreateJustService(t *testing.T) { deployer := &LatticeServiceStackDeployer{ log: gwlog.FallbackLogger, cloud: mockCloud, - k8sclient: mockClient, + k8sClient: mockClient, latticeServiceManager: mockServiceManager, targetGroupManager: mockTargetGroupManager, targetsManager: mockTargetsManager, @@ -179,7 +182,7 @@ func Test_latticeServiceStackDeployer_DeleteService(t *testing.T) { deployer := &LatticeServiceStackDeployer{ log: gwlog.FallbackLogger, cloud: mockCloud, - k8sclient: mockClient, + k8sClient: mockClient, latticeServiceManager: mockServiceManager, targetGroupManager: mockTargetGroupManager, listenerManager: mockListenerManager, @@ -237,7 +240,7 @@ func Test_latticeServiceStackDeployer_DeleteAllResources(t *testing.T) { deployer := &LatticeServiceStackDeployer{ log: gwlog.FallbackLogger, cloud: mockCloud, - k8sclient: mockClient, + k8sClient: mockClient, latticeServiceManager: mockServiceManager, targetGroupManager: mockTargetGroupManager, listenerManager: mockListenerManager,