Fix Gatewayproxy Controller and Re-Enable APIGW v2 Controller (#20508)

re-enable apigw controller, fix typo in key name for metadata for
gatewayproxy
This commit is contained in:
John Maguire 2024-02-06 13:55:55 -05:00 committed by GitHub
parent 49e6c0232d
commit 24e9603d9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -25,7 +25,10 @@ import (
) )
// ControllerName is the name for this controller. It's used for logging or status keys. // 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 // Controller is responsible for triggering reconciler for watched resources
func Controller(cache *cache.Cache, trustDomainFetcher sidecarproxy.TrustDomainFetcher, dc string, defaultAllow bool) *controller.Controller { 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 return nil
} }
switch workload.Metadata["gateway-type"] { switch workload.Metadata[GatewayKindMetadataKey] {
case meshgateways.GatewayKind: case meshgateways.GatewayKind:
rt.Logger.Trace("workload is a mesh-gateway; reconciling", "workload", workloadID, "workloadData", workload.Data) rt.Logger.Trace("workload is a mesh-gateway; reconciling", "workload", workloadID, "workloadData", workload.Data)
return r.reconcileMeshGatewayProxyState(ctx, dataFetcher, workload, rt, req) return r.reconcileMeshGatewayProxyState(ctx, dataFetcher, workload, rt, req)

View File

@ -6,6 +6,7 @@ package controllers
import ( import (
"context" "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/gatewayproxy"
"github.com/hashicorp/consul/internal/mesh/internal/controllers/meshconfiguration" "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(meshgateways.Controller())
mgr.Register(meshconfiguration.Controller()) mgr.Register(meshconfiguration.Controller())
// This controller is currently configured to watch types which aren't registered and produces infinite mgr.Register(apigateways.Controller())
// errors because of this. Once the watched types are in place we should uncomment this.
// mgr.Register(apigateways.Controller())
} }