From 22951d2f9c48ae2f898706fd9856cfdac6778a69 Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Thu, 18 Jan 2024 18:54:16 +0100 Subject: [PATCH] fix(gateway): make MeshHTTPRoute-based routing available to plugins (#8916) Signed-off-by: Mike Beaumont --- .../policies/meshhttproute/plugin/v1alpha1/plugin.go | 7 ++++++- pkg/plugins/runtime/gateway/plugin.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/policies/meshhttproute/plugin/v1alpha1/plugin.go b/pkg/plugins/policies/meshhttproute/plugin/v1alpha1/plugin.go index c0cc21c765e1..1b4bdd5ddbc7 100644 --- a/pkg/plugins/policies/meshhttproute/plugin/v1alpha1/plugin.go +++ b/pkg/plugins/policies/meshhttproute/plugin/v1alpha1/plugin.go @@ -120,7 +120,8 @@ func ApplyToGateway( return nil } - for _, info := range plugin_gateway.ExtractGatewayListeners(proxy) { + listeners := plugin_gateway.ExtractGatewayListeners(proxy) + for listenerIndex, info := range listeners { address := proxy.Dataplane.Spec.GetNetworking().Address port := info.Listener.Port inboundListener := rules.InboundListener{ @@ -187,6 +188,10 @@ func ApplyToGateway( return hostInfos[i].Host.Hostname > hostInfos[j].Host.Hostname }) + info.HostInfos = hostInfos + listeners[listenerIndex] = info + plugin_gateway.SetGatewayListeners(proxy, listeners) + cdsResources, err := generateGatewayClusters(ctx, xdsCtx, info, hostInfos) if err != nil { return err diff --git a/pkg/plugins/runtime/gateway/plugin.go b/pkg/plugins/runtime/gateway/plugin.go index 79c3157f3409..e96cc6912dbb 100644 --- a/pkg/plugins/runtime/gateway/plugin.go +++ b/pkg/plugins/runtime/gateway/plugin.go @@ -62,6 +62,10 @@ func ExtractGatewayListeners(proxy *core_xds.Proxy) []GatewayListenerInfo { return ext.([]GatewayListenerInfo) } +func SetGatewayListeners(proxy *core_xds.Proxy, infos []GatewayListenerInfo) { + proxy.RuntimeExtensions[metadata.PluginName] = infos +} + func (p *plugin) AfterBootstrap(context *core_plugins.MutablePluginContext, config core_plugins.PluginConfig) error { // Insert our resolver before the default so that we can intercept // builtin gateway dataplanes.