peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
// PeeringToken identifies a peer in order for a connection to be established.
|
|
|
|
type PeeringToken struct {
|
2022-11-08 20:55:18 +00:00
|
|
|
CA []string
|
|
|
|
ManualServerAddresses []string
|
|
|
|
ServerAddresses []string
|
|
|
|
ServerName string
|
|
|
|
PeerID string
|
|
|
|
EstablishmentSecret string
|
|
|
|
Remote PeeringTokenRemote
|
2022-10-05 13:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PeeringTokenRemote struct {
|
|
|
|
Partition string
|
|
|
|
Datacenter string
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
}
|
2022-05-06 19:35:31 +00:00
|
|
|
|
2022-06-06 19:20:41 +00:00
|
|
|
type IndexedExportedServiceList struct {
|
|
|
|
Services map[string]ServiceList
|
|
|
|
QueryMeta
|
|
|
|
}
|
|
|
|
|
2022-05-19 19:21:44 +00:00
|
|
|
// NOTE: this is not serialized via msgpack so it can be changed without concern.
|
|
|
|
type ExportedServiceList struct {
|
|
|
|
// Services is a list of exported services that apply to both standard
|
|
|
|
// service discovery and service mesh.
|
|
|
|
Services []ServiceName
|
|
|
|
|
2022-06-27 19:37:18 +00:00
|
|
|
// DiscoChains is a map of service names to their exported discovery chains
|
|
|
|
// for service mesh purposes as defined in the exported-services
|
|
|
|
// configuration entry.
|
|
|
|
DiscoChains map[ServiceName]ExportedDiscoveryChainInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: this is not serialized via msgpack so it can be changed without concern.
|
|
|
|
type ExportedDiscoveryChainInfo struct {
|
|
|
|
// Protocol is the overall protocol associated with this discovery chain.
|
|
|
|
Protocol string
|
|
|
|
|
|
|
|
// TCPTargets is the list of discovery chain targets that are reachable by
|
|
|
|
// this discovery chain.
|
|
|
|
//
|
|
|
|
// NOTE: this is only populated if Protocol=tcp.
|
|
|
|
TCPTargets []*DiscoveryTarget
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i ExportedDiscoveryChainInfo) Equal(o ExportedDiscoveryChainInfo) bool {
|
|
|
|
switch {
|
|
|
|
case i.Protocol != o.Protocol:
|
|
|
|
return false
|
|
|
|
case len(i.TCPTargets) != len(o.TCPTargets):
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for j := 0; j < len(i.TCPTargets); j++ {
|
|
|
|
if i.TCPTargets[j].ID != o.TCPTargets[j].ID {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2022-05-25 17:37:44 +00:00
|
|
|
|
2022-06-27 19:37:18 +00:00
|
|
|
return true
|
2022-05-19 19:21:44 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 19:59:36 +00:00
|
|
|
// ListAllDiscoveryChains returns all discovery chains (union of Services and DiscoChains).
|
2022-06-27 19:37:18 +00:00
|
|
|
func (list *ExportedServiceList) ListAllDiscoveryChains() map[ServiceName]ExportedDiscoveryChainInfo {
|
|
|
|
chainsByName := make(map[ServiceName]ExportedDiscoveryChainInfo)
|
2022-05-19 19:21:44 +00:00
|
|
|
if list == nil {
|
|
|
|
return chainsByName
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, svc := range list.Services {
|
2022-06-27 19:37:18 +00:00
|
|
|
chainsByName[svc] = list.DiscoChains[svc]
|
2022-05-19 19:21:44 +00:00
|
|
|
}
|
2022-06-27 19:37:18 +00:00
|
|
|
for chainName, info := range list.DiscoChains {
|
|
|
|
chainsByName[chainName] = info
|
2022-05-19 19:21:44 +00:00
|
|
|
}
|
|
|
|
return chainsByName
|
|
|
|
}
|