Skip to content

Commit

Permalink
sidecar-proxy refactor (#17336) (#17366)
Browse files Browse the repository at this point in the history
  • Loading branch information
erichaberkorn authored May 15, 2023
1 parent 64c2aa7 commit 29f7c23
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,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)
Expand Down
4 changes: 2 additions & 2 deletions agent/sidecar_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/consul/agent/structs"
)

const sidecarIDSuffix = "-sidecar-proxy"
const sidecarIDSuffix = structs.SidecarProxySuffix

func sidecarIDFromServiceID(serviceID string) string {
return serviceID + sidecarIDSuffix
Expand Down Expand Up @@ -93,7 +93,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
Expand Down
1 change: 1 addition & 0 deletions agent/structs/config_entry_exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (e *ExportedServicesConfigEntry) ToMap() map[string]map[string][]string {
consumers = append(consumers, c.Partition)
}
resp[svc.Namespace][svc.Name] = consumers
resp[svc.Namespace][svc.Name+SidecarProxySuffix] = consumers
}
}
return resp
Expand Down
2 changes: 2 additions & 0 deletions agent/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,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
Expand Down

0 comments on commit 29f7c23

Please sign in to comment.