Skip to content

Commit

Permalink
Backport of [NET-10246] use correct enterprise meta for service name …
Browse files Browse the repository at this point in the history
…for LinkedService into release/1.19.x (#21533)

* backport of commit f5cec2e

* backport of commit 8e63265

---------

Co-authored-by: jm96441n <john.maguire@hashicorp.com>
  • Loading branch information
hc-github-team-consul-core and jm96441n authored Jul 10, 2024
1 parent 3ad8611 commit f050396
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/21382.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
terminating-gateway: **(Enterprise Only)** Fixed issue where enterprise metadata applied to linked services was the terminating-gateways enterprise metadata and not the linked services enterprise metadata.
```
7 changes: 3 additions & 4 deletions agent/consul/state/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ func ensureServiceTxn(tx WriteTxn, idx uint64, node string, preserveIndexes bool
}
if conf != nil {
termGatewayConf := conf.(*structs.TerminatingGatewayConfigEntry)
addrs, err := getTermGatewayVirtualIPs(tx, idx, termGatewayConf.Services, &svc.EnterpriseMeta)
addrs, err := getTermGatewayVirtualIPs(tx, idx, termGatewayConf.Services)
if err != nil {
return err
}
Expand Down Expand Up @@ -3585,11 +3585,10 @@ func getTermGatewayVirtualIPs(
tx WriteTxn,
idx uint64,
services []structs.LinkedService,
entMeta *acl.EnterpriseMeta,
) (map[string]structs.ServiceAddress, error) {
addrs := make(map[string]structs.ServiceAddress, len(services))
for _, s := range services {
sn := structs.ServiceName{Name: s.Name, EnterpriseMeta: *entMeta}
sn := structs.ServiceName{Name: s.Name, EnterpriseMeta: s.EnterpriseMeta}
// Terminating Gateways cannot route to services in peered clusters
psn := structs.PeeredServiceName{ServiceName: sn, Peer: structs.DefaultPeerKeyword}
vip, err := assignServiceVirtualIP(tx, idx, psn)
Expand All @@ -3606,7 +3605,7 @@ func getTermGatewayVirtualIPs(
func updateTerminatingGatewayVirtualIPs(tx WriteTxn, idx uint64, conf *structs.TerminatingGatewayConfigEntry, entMeta *acl.EnterpriseMeta) error {
// Build the current map of services with virtual IPs for this gateway
services := conf.Services
addrs, err := getTermGatewayVirtualIPs(tx, idx, services, entMeta)
addrs, err := getTermGatewayVirtualIPs(tx, idx, services)
if err != nil {
return err
}
Expand Down

0 comments on commit f050396

Please sign in to comment.