Update normalization of route refs (#16789)

* Use merge of enterprise meta's rather than new custom method

* Add merge logic for tcp routes

* Add changelog

* Normalize certificate refs on gateways

* Fix infinite call loop

* Explicitly call enterprise meta
This commit is contained in:
John Maguire 2023-03-28 11:23:49 -04:00 committed by GitHub
parent 12be12f3a4
commit c833464daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

3
.changelog/16789.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
gateway: **(Enterprise only)** Fix bug where parent refs and service refs for a route in the same namespace as the route would fallback to the default namespace if the namespace was not specified in the configuration rather than falling back to the routes namespace.
```

View File

@ -755,6 +755,7 @@ func (e *APIGatewayConfigEntry) Normalize() error {
if cert.Kind == "" { if cert.Kind == "" {
cert.Kind = InlineCertificate cert.Kind = InlineCertificate
} }
cert.EnterpriseMeta.Merge(e.GetEnterpriseMeta())
cert.EnterpriseMeta.Normalize() cert.EnterpriseMeta.Normalize()
listener.TLS.Certificates[i] = cert listener.TLS.Certificates[i] = cert
@ -985,11 +986,13 @@ func (e *BoundAPIGatewayConfigEntry) GetMeta() map[string]string { return e.Meta
func (e *BoundAPIGatewayConfigEntry) Normalize() error { func (e *BoundAPIGatewayConfigEntry) Normalize() error {
for i, listener := range e.Listeners { for i, listener := range e.Listeners {
for j, route := range listener.Routes { for j, route := range listener.Routes {
route.EnterpriseMeta.Merge(&e.EnterpriseMeta)
route.EnterpriseMeta.Normalize() route.EnterpriseMeta.Normalize()
listener.Routes[j] = route listener.Routes[j] = route
} }
for j, cert := range listener.Certificates { for j, cert := range listener.Certificates {
cert.EnterpriseMeta.Merge(&e.EnterpriseMeta)
cert.EnterpriseMeta.Normalize() cert.EnterpriseMeta.Normalize()
listener.Certificates[j] = cert listener.Certificates[j] = cert

View File

@ -81,6 +81,7 @@ func (e *HTTPRouteConfigEntry) Normalize() error {
if parent.Kind == "" { if parent.Kind == "" {
parent.Kind = APIGateway parent.Kind = APIGateway
} }
parent.EnterpriseMeta.Merge(e.GetEnterpriseMeta())
parent.EnterpriseMeta.Normalize() parent.EnterpriseMeta.Normalize()
e.Parents[i] = parent e.Parents[i] = parent
} }
@ -91,7 +92,7 @@ func (e *HTTPRouteConfigEntry) Normalize() error {
} }
for j, service := range rule.Services { for j, service := range rule.Services {
rule.Services[j] = normalizeHTTPService(service) rule.Services[j] = e.normalizeHTTPService(service)
} }
e.Rules[i] = rule e.Rules[i] = rule
} }
@ -99,7 +100,8 @@ func (e *HTTPRouteConfigEntry) Normalize() error {
return nil return nil
} }
func normalizeHTTPService(service HTTPService) HTTPService { func (e *HTTPRouteConfigEntry) normalizeHTTPService(service HTTPService) HTTPService {
service.EnterpriseMeta.Merge(e.GetEnterpriseMeta())
service.EnterpriseMeta.Normalize() service.EnterpriseMeta.Normalize()
if service.Weight <= 0 { if service.Weight <= 0 {
service.Weight = 1 service.Weight = 1
@ -507,11 +509,13 @@ func (e *TCPRouteConfigEntry) Normalize() error {
if parent.Kind == "" { if parent.Kind == "" {
parent.Kind = APIGateway parent.Kind = APIGateway
} }
parent.EnterpriseMeta.Merge(e.GetEnterpriseMeta())
parent.EnterpriseMeta.Normalize() parent.EnterpriseMeta.Normalize()
e.Parents[i] = parent e.Parents[i] = parent
} }
for i, service := range e.Services { for i, service := range e.Services {
service.EnterpriseMeta.Merge(e.GetEnterpriseMeta())
service.EnterpriseMeta.Normalize() service.EnterpriseMeta.Normalize()
e.Services[i] = service e.Services[i] = service
} }