[NET-10246] use correct enterprise meta for service name for LinkedService (#21382)

* use correct enterprise meta for service name for LinkedService

* add changelog
This commit is contained in:
John Maguire 2024-07-10 10:55:53 -04:00 committed by GitHub
parent bc6e889eef
commit c0faddbe1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

3
.changelog/21382.txt Normal file
View File

@ -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.
```

View File

@ -942,7 +942,7 @@ func ensureServiceTxn(tx WriteTxn, idx uint64, node string, preserveIndexes bool
} }
if conf != nil { if conf != nil {
termGatewayConf := conf.(*structs.TerminatingGatewayConfigEntry) termGatewayConf := conf.(*structs.TerminatingGatewayConfigEntry)
addrs, err := getTermGatewayVirtualIPs(tx, idx, termGatewayConf.Services, &svc.EnterpriseMeta) addrs, err := getTermGatewayVirtualIPs(tx, idx, termGatewayConf.Services)
if err != nil { if err != nil {
return err return err
} }
@ -3585,11 +3585,10 @@ func getTermGatewayVirtualIPs(
tx WriteTxn, tx WriteTxn,
idx uint64, idx uint64,
services []structs.LinkedService, services []structs.LinkedService,
entMeta *acl.EnterpriseMeta,
) (map[string]structs.ServiceAddress, error) { ) (map[string]structs.ServiceAddress, error) {
addrs := make(map[string]structs.ServiceAddress, len(services)) addrs := make(map[string]structs.ServiceAddress, len(services))
for _, s := range 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 // Terminating Gateways cannot route to services in peered clusters
psn := structs.PeeredServiceName{ServiceName: sn, Peer: structs.DefaultPeerKeyword} psn := structs.PeeredServiceName{ServiceName: sn, Peer: structs.DefaultPeerKeyword}
vip, err := assignServiceVirtualIP(tx, idx, psn) vip, err := assignServiceVirtualIP(tx, idx, psn)
@ -3606,7 +3605,7 @@ func getTermGatewayVirtualIPs(
func updateTerminatingGatewayVirtualIPs(tx WriteTxn, idx uint64, conf *structs.TerminatingGatewayConfigEntry, entMeta *acl.EnterpriseMeta) error { 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 // Build the current map of services with virtual IPs for this gateway
services := conf.Services services := conf.Services
addrs, err := getTermGatewayVirtualIPs(tx, idx, services, entMeta) addrs, err := getTermGatewayVirtualIPs(tx, idx, services)
if err != nil { if err != nil {
return err return err
} }