From 24e9603d9b92fa9f65c46f5257683b17ef99b5c5 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 6 Feb 2024 13:55:55 -0500 Subject: [PATCH] Fix Gatewayproxy Controller and Re-Enable APIGW v2 Controller (#20508) re-enable apigw controller, fix typo in key name for metadata for gatewayproxy --- .../mesh/internal/controllers/gatewayproxy/controller.go | 7 +++++-- internal/mesh/internal/controllers/register.go | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/mesh/internal/controllers/gatewayproxy/controller.go b/internal/mesh/internal/controllers/gatewayproxy/controller.go index 9443c8993e..39358db3de 100644 --- a/internal/mesh/internal/controllers/gatewayproxy/controller.go +++ b/internal/mesh/internal/controllers/gatewayproxy/controller.go @@ -25,7 +25,10 @@ import ( ) // ControllerName is the name for this controller. It's used for logging or status keys. -const ControllerName = "consul.io/gateway-proxy" +const ( + ControllerName = "consul.io/gateway-proxy" + GatewayKindMetadataKey = "gateway-kind" +) // Controller is responsible for triggering reconciler for watched resources func Controller(cache *cache.Cache, trustDomainFetcher sidecarproxy.TrustDomainFetcher, dc string, defaultAllow bool) *controller.Controller { @@ -75,7 +78,7 @@ func (r *reconciler) Reconcile(ctx context.Context, rt controller.Runtime, req c return nil } - switch workload.Metadata["gateway-type"] { + switch workload.Metadata[GatewayKindMetadataKey] { case meshgateways.GatewayKind: rt.Logger.Trace("workload is a mesh-gateway; reconciling", "workload", workloadID, "workloadData", workload.Data) return r.reconcileMeshGatewayProxyState(ctx, dataFetcher, workload, rt, req) diff --git a/internal/mesh/internal/controllers/register.go b/internal/mesh/internal/controllers/register.go index 1729a51498..46cab2f7c1 100644 --- a/internal/mesh/internal/controllers/register.go +++ b/internal/mesh/internal/controllers/register.go @@ -6,6 +6,7 @@ package controllers import ( "context" + "github.com/hashicorp/consul/internal/mesh/internal/controllers/apigateways" "github.com/hashicorp/consul/internal/mesh/internal/controllers/gatewayproxy" "github.com/hashicorp/consul/internal/mesh/internal/controllers/meshconfiguration" @@ -58,7 +59,5 @@ func Register(mgr *controller.Manager, deps Dependencies) { mgr.Register(meshgateways.Controller()) mgr.Register(meshconfiguration.Controller()) - // This controller is currently configured to watch types which aren't registered and produces infinite - // errors because of this. Once the watched types are in place we should uncomment this. - // mgr.Register(apigateways.Controller()) + mgr.Register(apigateways.Controller()) }