diff --git a/.changelog/16789.txt b/.changelog/16789.txt new file mode 100644 index 000000000..ed25e11bb --- /dev/null +++ b/.changelog/16789.txt @@ -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. +``` diff --git a/agent/structs/config_entry_gateways.go b/agent/structs/config_entry_gateways.go index 5309af35a..32fd966f6 100644 --- a/agent/structs/config_entry_gateways.go +++ b/agent/structs/config_entry_gateways.go @@ -755,6 +755,7 @@ func (e *APIGatewayConfigEntry) Normalize() error { if cert.Kind == "" { cert.Kind = InlineCertificate } + cert.EnterpriseMeta.Merge(e.GetEnterpriseMeta()) cert.EnterpriseMeta.Normalize() listener.TLS.Certificates[i] = cert @@ -985,11 +986,13 @@ func (e *BoundAPIGatewayConfigEntry) GetMeta() map[string]string { return e.Meta func (e *BoundAPIGatewayConfigEntry) Normalize() error { for i, listener := range e.Listeners { for j, route := range listener.Routes { + route.EnterpriseMeta.Merge(&e.EnterpriseMeta) route.EnterpriseMeta.Normalize() listener.Routes[j] = route } for j, cert := range listener.Certificates { + cert.EnterpriseMeta.Merge(&e.EnterpriseMeta) cert.EnterpriseMeta.Normalize() listener.Certificates[j] = cert diff --git a/agent/structs/config_entry_routes.go b/agent/structs/config_entry_routes.go index 70a306559..ca092c07d 100644 --- a/agent/structs/config_entry_routes.go +++ b/agent/structs/config_entry_routes.go @@ -81,6 +81,7 @@ func (e *HTTPRouteConfigEntry) Normalize() error { if parent.Kind == "" { parent.Kind = APIGateway } + parent.EnterpriseMeta.Merge(e.GetEnterpriseMeta()) parent.EnterpriseMeta.Normalize() e.Parents[i] = parent } @@ -91,7 +92,7 @@ func (e *HTTPRouteConfigEntry) Normalize() error { } for j, service := range rule.Services { - rule.Services[j] = normalizeHTTPService(service) + rule.Services[j] = e.normalizeHTTPService(service) } e.Rules[i] = rule } @@ -99,7 +100,8 @@ func (e *HTTPRouteConfigEntry) Normalize() error { return nil } -func normalizeHTTPService(service HTTPService) HTTPService { +func (e *HTTPRouteConfigEntry) normalizeHTTPService(service HTTPService) HTTPService { + service.EnterpriseMeta.Merge(e.GetEnterpriseMeta()) service.EnterpriseMeta.Normalize() if service.Weight <= 0 { service.Weight = 1 @@ -507,11 +509,13 @@ func (e *TCPRouteConfigEntry) Normalize() error { if parent.Kind == "" { parent.Kind = APIGateway } + parent.EnterpriseMeta.Merge(e.GetEnterpriseMeta()) parent.EnterpriseMeta.Normalize() e.Parents[i] = parent } for i, service := range e.Services { + service.EnterpriseMeta.Merge(e.GetEnterpriseMeta()) service.EnterpriseMeta.Normalize() e.Services[i] = service }