Skip to content

Commit

Permalink
Backport of Update normalization of route refs into release/1.15.x (#…
Browse files Browse the repository at this point in the history
…16799)

* backport of commit 7f5e9ba

* backport of commit 67b8537

* backport of commit b47040d

* backport of commit 079ed98

* Fix infinite call loop

* Explicitly call enterprise meta

---------

Co-authored-by: jm96441n <[email protected]>
  • Loading branch information
hc-github-team-consul-core and jm96441n authored Mar 28, 2023
1 parent 1553036 commit 7d44a4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit 7d44a4c

Please sign in to comment.