Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Update normalization of route refs into release/1.15.x #16799

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/16789.txt
Original file line number Diff line number Diff line change
@@ -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.
```
3 changes: 3 additions & 0 deletions agent/structs/config_entry_gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions agent/structs/config_entry_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -91,15 +92,16 @@ 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
}

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
Expand Down Expand Up @@ -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
}
Expand Down