Skip to content

Commit ac4e66f

Browse files
authored
[Bugfix] [Platform] Sort Headers in Envoy (#1994)
1 parent e8688c4 commit ac4e66f

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- (Feature) (Platform) ArangoRoute Redirect
2222
- (Feature) (Platform) Request ID & Header Standardization
2323
- (Feature) (Platform) Install multi type support
24+
- (Bugfix) (Platform) Sort Headers in Envoy
2425

2526
## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
2627
- (Documentation) Add ArangoPlatformStorage Docs & Examples

pkg/deployment/resources/gateway/gateway_config_destination.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3434

3535
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
36+
"github.com/arangodb/kube-arangodb/pkg/util"
3637
utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants"
3738
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3839
)
@@ -163,7 +164,8 @@ func (c *ConfigDestination) RenderRoute(name, prefix string) (*pbEnvoyRouteV3.Ro
163164
}
164165
var headers []*pbEnvoyCoreV3.HeaderValueOption
165166

166-
for k, v := range c.ResponseHeaders {
167+
for _, k := range util.SortKeys(c.ResponseHeaders) {
168+
v := c.ResponseHeaders[k]
167169
headers = append(headers, &pbEnvoyCoreV3.HeaderValueOption{
168170
Header: &pbEnvoyCoreV3.HeaderValue{
169171
Key: k,

pkg/deployment/resources/gateway/gateway_config_test.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc"
3434
)
3535

36-
func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t *testing.T, b *pbEnvoyBootstrapV3.Bootstrap)) {
36+
func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t *testing.T, b *pbEnvoyBootstrapV3.Bootstrap)) string {
3737
require.NoError(t, cfg.Validate())
3838

3939
data, checksum, obj, err := cfg.RenderYAML()
@@ -47,6 +47,8 @@ func renderAndPrintGatewayConfig(t *testing.T, cfg Config, validates ...func(t *
4747
validates[id](t, obj)
4848
})
4949
}
50+
51+
return checksum
5052
}
5153

5254
func Test_GatewayConfig(t *testing.T) {
@@ -467,15 +469,23 @@ func Test_GatewayConfig(t *testing.T) {
467469
})
468470

469471
t.Run("Default", func(t *testing.T) {
470-
renderAndPrintGatewayConfig(t, Config{
472+
cfg := Config{
471473
DefaultDestination: ConfigDestination{
472474
Targets: []ConfigDestinationTarget{
473475
{
474476
Host: "127.0.0.1",
475477
Port: 12345,
476478
},
479+
{
480+
Host: "127.0.0.1",
481+
Port: 12346,
482+
},
483+
{
484+
Host: "127.0.0.1",
485+
Port: 12347,
486+
},
477487
},
478-
Path: util.NewType("/test/path/"),
488+
Path: util.NewType("/"),
479489
Type: util.NewType(ConfigDestinationTypeHTTPS),
480490
},
481491
Destinations: ConfigDestinations{
@@ -485,8 +495,20 @@ func Test_GatewayConfig(t *testing.T) {
485495
},
486496
Path: util.NewType("/test/path/"),
487497
Type: util.NewType(ConfigDestinationTypeRedirect),
498+
ResponseHeaders: map[string]string{
499+
"A": "B",
500+
"C": "C",
501+
"D": "D",
502+
},
488503
},
489504
},
490-
})
505+
}
506+
a := renderAndPrintGatewayConfig(t, cfg)
507+
508+
for id := 0; id < 128; id++ {
509+
t.Run(fmt.Sprintf("id:%d", id), func(t *testing.T) {
510+
require.Equal(t, a, renderAndPrintGatewayConfig(t, cfg))
511+
})
512+
}
491513
})
492514
}

0 commit comments

Comments
 (0)