From 9896d2d037edf945c3ee114c5cf52ad0c560535d Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Wed, 19 Nov 2025 09:47:18 +0000 Subject: [PATCH] [Bugfix] [Platform] Sort Headers in Envoy --- CHANGELOG.md | 1 + .../gateway/gateway_config_destination.go | 4 ++- .../resources/gateway/gateway_config_test.go | 30 ++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 877cfbf9d..13de690d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - (Feature) (Platform) ArangoRoute Redirect - (Feature) (Platform) Request ID & Header Standardization - (Feature) (Platform) Install multi type support +- (Bugfix) (Platform) Sort Headers in Envoy ## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07) - (Documentation) Add ArangoPlatformStorage Docs & Examples diff --git a/pkg/deployment/resources/gateway/gateway_config_destination.go b/pkg/deployment/resources/gateway/gateway_config_destination.go index 1d64ce123..ac41e87ed 100644 --- a/pkg/deployment/resources/gateway/gateway_config_destination.go +++ b/pkg/deployment/resources/gateway/gateway_config_destination.go @@ -33,6 +33,7 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + "github.com/arangodb/kube-arangodb/pkg/util" utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -163,7 +164,8 @@ func (c *ConfigDestination) RenderRoute(name, prefix string) (*pbEnvoyRouteV3.Ro } var headers []*pbEnvoyCoreV3.HeaderValueOption - for k, v := range c.ResponseHeaders { + for _, k := range util.SortKeys(c.ResponseHeaders) { + v := c.ResponseHeaders[k] headers = append(headers, &pbEnvoyCoreV3.HeaderValueOption{ Header: &pbEnvoyCoreV3.HeaderValue{ Key: k, diff --git a/pkg/deployment/resources/gateway/gateway_config_test.go b/pkg/deployment/resources/gateway/gateway_config_test.go index 6ea76e3ff..6869f9425 100644 --- a/pkg/deployment/resources/gateway/gateway_config_test.go +++ b/pkg/deployment/resources/gateway/gateway_config_test.go @@ -33,7 +33,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc" ) -func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t *testing.T, b *pbEnvoyBootstrapV3.Bootstrap)) { +func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t *testing.T, b *pbEnvoyBootstrapV3.Bootstrap)) string { require.NoError(t, cfg.Validate()) data, checksum, obj, err := cfg.RenderYAML() @@ -47,6 +47,8 @@ func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t * validates[id](t, obj) }) } + + return checksum } func Test_GatewayConfig(t *testing.T) { @@ -467,15 +469,23 @@ func Test_GatewayConfig(t *testing.T) { }) t.Run("Default", func(t *testing.T) { - renderAndPrintGatewayConfig(t, Config{ + cfg := Config{ DefaultDestination: ConfigDestination{ Targets: []ConfigDestinationTarget{ { Host: "127.0.0.1", Port: 12345, }, + { + Host: "127.0.0.1", + Port: 12346, + }, + { + Host: "127.0.0.1", + Port: 12347, + }, }, - Path: util.NewType("/test/path/"), + Path: util.NewType("/"), Type: util.NewType(ConfigDestinationTypeHTTPS), }, Destinations: ConfigDestinations{ @@ -485,8 +495,20 @@ func Test_GatewayConfig(t *testing.T) { }, Path: util.NewType("/test/path/"), Type: util.NewType(ConfigDestinationTypeRedirect), + ResponseHeaders: map[string]string{ + "A": "B", + "C": "C", + "D": "D", + }, }, }, - }) + } + a := renderAndPrintGatewayConfig(t, cfg) + + for id := 0; id < 128; id++ { + t.Run(fmt.Sprintf("id:%d", id), func(t *testing.T) { + require.Equal(t, a, renderAndPrintGatewayConfig(t, cfg)) + }) + } }) }