sidecar-proxy refactor (#17328)

This commit is contained in:
Eric Haberkorn 2023-05-12 16:49:42 -04:00 committed by GitHub
parent 2edfda998a
commit 8bb16567cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -33,6 +33,7 @@ func (e *SimplifiedExportedServices) ToPartitionMap() map[string]map[string][]st
}
}
resp[svc.Namespace][svc.Name] = consumers
resp[svc.Namespace][svc.Name+structs.SidecarProxySuffix] = consumers
}
}
return resp

View File

@ -747,7 +747,7 @@ func (m *subscriptionManager) NotifyStandardService(
//
// This name was chosen to match existing "sidecar service" generation logic
// and similar logic in the Service Identity synthetic ACL policies.
const syntheticProxyNameSuffix = "-sidecar-proxy"
const syntheticProxyNameSuffix = structs.SidecarProxySuffix
func generateProxyNameForDiscoveryChain(sn structs.ServiceName) structs.ServiceName {
return structs.NewServiceName(sn.Name+syntheticProxyNameSuffix, &sn.EnterpriseMeta)

View File

@ -13,7 +13,7 @@ import (
"github.com/hashicorp/consul/agent/structs"
)
const sidecarIDSuffix = "-sidecar-proxy"
const sidecarIDSuffix = structs.SidecarProxySuffix
func sidecarIDFromServiceID(serviceID string) string {
return serviceID + sidecarIDSuffix
@ -96,7 +96,7 @@ func sidecarServiceFromNodeService(ns *structs.NodeService, token string) (*stru
sidecar.Kind = structs.ServiceKindConnectProxy
}
if sidecar.Service == "" {
sidecar.Service = ns.Service + "-sidecar-proxy"
sidecar.Service = ns.Service + structs.SidecarProxySuffix
}
if sidecar.Address == "" {
// Inherit address from the service if it's provided

View File

@ -1270,6 +1270,8 @@ func (a ServiceAddress) ToAPIServiceAddress() api.ServiceAddress {
return api.ServiceAddress{Address: a.Address, Port: a.Port}
}
const SidecarProxySuffix = "-sidecar-proxy"
// NodeService is a service provided by a node
type NodeService struct {
// Kind is the kind of service this is. Different kinds of services may