proxycfg: watch service-defaults config entries (#15025)

To support Destinations on the service-defaults (for tproxy with terminating gateway), we need to now also make servers watch service-defaults config entries.
This commit is contained in:
Iryna Shustava 2022-10-24 12:50:28 -06:00 committed by GitHub
parent 06f583a7c2
commit a3a6743e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 2648 additions and 618 deletions

View File

@ -335,4 +335,11 @@ func (c *FSM) registerStreamSnapshotHandlers() {
if err != nil {
panic(fmt.Errorf("fatal error encountered registering streaming snapshot handlers: %w", err))
}
err = c.deps.Publisher.RegisterHandler(state.EventTopicServiceDefaults, func(req stream.SubscribeRequest, buf stream.SnapshotAppender) (uint64, error) {
return c.State().ServiceDefaultsSnapshot(req, buf)
}, true)
if err != nil {
panic(fmt.Errorf("fatal error encountered registering streaming snapshot handlers: %w", err))
}
}

View File

@ -16,6 +16,7 @@ var configEntryKindToTopic = map[string]stream.Topic{
structs.ServiceResolver: EventTopicServiceResolver,
structs.IngressGateway: EventTopicIngressGateway,
structs.ServiceIntentions: EventTopicServiceIntentions,
structs.ServiceDefaults: EventTopicServiceDefaults,
}
// EventSubjectConfigEntry is a stream.Subject used to route and receive events
@ -110,6 +111,12 @@ func (s *Store) ServiceIntentionsSnapshot(req stream.SubscribeRequest, buf strea
return s.configEntrySnapshot(structs.ServiceIntentions, req, buf)
}
// ServiceDefaultsSnapshot is a stream.SnapshotFunc that returns a snapshot of
// service-defaults config entries.
func (s *Store) ServiceDefaultsSnapshot(req stream.SubscribeRequest, buf stream.SnapshotAppender) (uint64, error) {
return s.configEntrySnapshot(structs.ServiceDefaults, req, buf)
}
func (s *Store) configEntrySnapshot(kind string, req stream.SubscribeRequest, buf stream.SnapshotAppender) (uint64, error) {
var (
idx uint64

View File

@ -178,6 +178,47 @@ func TestConfigEntryEventsFromChanges(t *testing.T) {
},
},
},
"upsert service defaults": {
mutate: func(tx *txn) error {
return ensureConfigEntryTxn(tx, 0, &structs.ServiceConfigEntry{
Name: "web",
})
},
events: []stream.Event{
{
Topic: EventTopicServiceDefaults,
Index: changeIndex,
Payload: EventPayloadConfigEntry{
Op: pbsubscribe.ConfigEntryUpdate_Upsert,
Value: &structs.ServiceConfigEntry{
Name: "web",
},
},
},
},
},
"delete service defaults": {
setup: func(tx *txn) error {
return ensureConfigEntryTxn(tx, 0, &structs.ServiceConfigEntry{
Name: "web",
})
},
mutate: func(tx *txn) error {
return deleteConfigEntryTxn(tx, 0, structs.ServiceDefaults, "web", nil)
},
events: []stream.Event{
{
Topic: EventTopicServiceDefaults,
Index: changeIndex,
Payload: EventPayloadConfigEntry{
Op: pbsubscribe.ConfigEntryUpdate_Delete,
Value: &structs.ServiceConfigEntry{
Name: "web",
},
},
},
},
},
}
for desc, tc := range testCases {
t.Run(desc, func(t *testing.T) {
@ -376,11 +417,11 @@ func TestServiceIntentionsSnapshot(t *testing.T) {
ixn1 := &structs.ServiceIntentionsConfigEntry{
Kind: structs.ServiceIntentions,
Name: "gw1",
Name: "svc1",
}
ixn2 := &structs.ServiceIntentionsConfigEntry{
Kind: structs.ServiceIntentions,
Name: "gw2",
Name: "svc2",
}
store := testStateStore(t)
@ -438,3 +479,71 @@ func TestServiceIntentionsSnapshot(t *testing.T) {
})
}
}
func TestServiceDefaultsSnapshot(t *testing.T) {
const index uint64 = 123
ixn1 := &structs.ServiceConfigEntry{
Kind: structs.ServiceDefaults,
Name: "svc1",
}
ixn2 := &structs.ServiceConfigEntry{
Kind: structs.ServiceDefaults,
Name: "svc2",
}
store := testStateStore(t)
require.NoError(t, store.EnsureConfigEntry(index, ixn1))
require.NoError(t, store.EnsureConfigEntry(index, ixn2))
testCases := map[string]struct {
subject stream.Subject
events []stream.Event
}{
"named entry": {
subject: EventSubjectConfigEntry{Name: ixn1.Name},
events: []stream.Event{
{
Topic: EventTopicServiceDefaults,
Index: index,
Payload: EventPayloadConfigEntry{
Op: pbsubscribe.ConfigEntryUpdate_Upsert,
Value: ixn1,
},
},
},
},
"wildcard": {
subject: stream.SubjectWildcard,
events: []stream.Event{
{
Topic: EventTopicServiceDefaults,
Index: index,
Payload: EventPayloadConfigEntry{
Op: pbsubscribe.ConfigEntryUpdate_Upsert,
Value: ixn1,
},
},
{
Topic: EventTopicServiceDefaults,
Index: index,
Payload: EventPayloadConfigEntry{
Op: pbsubscribe.ConfigEntryUpdate_Upsert,
Value: ixn2,
},
},
},
},
}
for desc, tc := range testCases {
t.Run(desc, func(t *testing.T) {
buf := &snapshotAppender{}
idx, err := store.ServiceDefaultsSnapshot(stream.SubscribeRequest{Subject: tc.subject}, buf)
require.NoError(t, err)
require.Equal(t, index, idx)
require.Len(t, buf.events, 1)
require.ElementsMatch(t, tc.events, buf.events[0])
})
}
}

View File

@ -38,7 +38,7 @@ func PBToStreamSubscribeRequest(req *pbsubscribe.SubscribeRequest, entMeta acl.E
EnterpriseMeta: entMeta,
PeerName: named.PeerName,
}
case EventTopicMeshConfig, EventTopicServiceResolver, EventTopicIngressGateway, EventTopicServiceIntentions:
case EventTopicMeshConfig, EventTopicServiceResolver, EventTopicIngressGateway, EventTopicServiceIntentions, EventTopicServiceDefaults:
subject = EventSubjectConfigEntry{
Name: named.Key,
EnterpriseMeta: &entMeta,

View File

@ -184,6 +184,7 @@ var (
EventTopicServiceResolver = pbsubscribe.Topic_ServiceResolver
EventTopicIngressGateway = pbsubscribe.Topic_IngressGateway
EventTopicServiceIntentions = pbsubscribe.Topic_ServiceIntentions
EventTopicServiceDefaults = pbsubscribe.Topic_ServiceDefaults
EventTopicServiceList = pbsubscribe.Topic_ServiceList
)

View File

@ -60,6 +60,8 @@ func newConfigEntryRequest(req *structs.ConfigEntryQuery, deps ServerDataSourceD
topic = pbsubscribe.Topic_ServiceResolver
case structs.IngressGateway:
topic = pbsubscribe.Topic_IngressGateway
case structs.ServiceDefaults:
topic = pbsubscribe.Topic_ServiceDefaults
default:
return nil, fmt.Errorf("cannot map config entry kind: %s to a topic", req.Kind)
}

View File

@ -20,6 +20,70 @@ func CookieConfigFromStructs(t *structs.CookieConfig, s *CookieConfig) {
s.TTL = structs.DurationToProto(t.TTL)
s.Path = t.Path
}
func DestinationConfigToStructs(s *DestinationConfig, t *structs.DestinationConfig) {
if s == nil {
return
}
t.Addresses = s.Addresses
t.Port = int(s.Port)
}
func DestinationConfigFromStructs(t *structs.DestinationConfig, s *DestinationConfig) {
if s == nil {
return
}
s.Addresses = t.Addresses
s.Port = int32(t.Port)
}
func ExposeConfigToStructs(s *ExposeConfig, t *structs.ExposeConfig) {
if s == nil {
return
}
t.Checks = s.Checks
{
t.Paths = make([]structs.ExposePath, len(s.Paths))
for i := range s.Paths {
if s.Paths[i] != nil {
ExposePathToStructs(s.Paths[i], &t.Paths[i])
}
}
}
}
func ExposeConfigFromStructs(t *structs.ExposeConfig, s *ExposeConfig) {
if s == nil {
return
}
s.Checks = t.Checks
{
s.Paths = make([]*ExposePath, len(t.Paths))
for i := range t.Paths {
{
var x ExposePath
ExposePathFromStructs(&t.Paths[i], &x)
s.Paths[i] = &x
}
}
}
}
func ExposePathToStructs(s *ExposePath, t *structs.ExposePath) {
if s == nil {
return
}
t.ListenerPort = int(s.ListenerPort)
t.Path = s.Path
t.LocalPathPort = int(s.LocalPathPort)
t.Protocol = s.Protocol
t.ParsedFromCheck = s.ParsedFromCheck
}
func ExposePathFromStructs(t *structs.ExposePath, s *ExposePath) {
if s == nil {
return
}
s.ListenerPort = int32(t.ListenerPort)
s.Path = t.Path
s.LocalPathPort = int32(t.LocalPathPort)
s.Protocol = t.Protocol
s.ParsedFromCheck = t.ParsedFromCheck
}
func GatewayServiceTLSConfigToStructs(s *GatewayServiceTLSConfig, t *structs.GatewayServiceTLSConfig) {
if s == nil {
return
@ -496,6 +560,18 @@ func MeshDirectionalTLSConfigFromStructs(t *structs.MeshDirectionalTLSConfig, s
s.TLSMaxVersion = tlsVersionFromStructs(t.TLSMaxVersion)
s.CipherSuites = cipherSuitesFromStructs(t.CipherSuites)
}
func MeshGatewayConfigToStructs(s *MeshGatewayConfig, t *structs.MeshGatewayConfig) {
if s == nil {
return
}
t.Mode = meshGatewayModeToStructs(s.Mode)
}
func MeshGatewayConfigFromStructs(t *structs.MeshGatewayConfig, s *MeshGatewayConfig) {
if s == nil {
return
}
s.Mode = meshGatewayModeFromStructs(t.Mode)
}
func MeshHTTPConfigToStructs(s *MeshHTTPConfig, t *structs.MeshHTTPConfig) {
if s == nil {
return
@ -538,6 +614,22 @@ func MeshTLSConfigFromStructs(t *structs.MeshTLSConfig, s *MeshTLSConfig) {
s.Outgoing = &x
}
}
func PassiveHealthCheckToStructs(s *PassiveHealthCheck, t *structs.PassiveHealthCheck) {
if s == nil {
return
}
t.Interval = structs.DurationFromProto(s.Interval)
t.MaxFailures = s.MaxFailures
t.EnforcingConsecutive5xx = pointerToUint32FromUint32(s.EnforcingConsecutive5Xx)
}
func PassiveHealthCheckFromStructs(t *structs.PassiveHealthCheck, s *PassiveHealthCheck) {
if s == nil {
return
}
s.Interval = structs.DurationToProto(t.Interval)
s.MaxFailures = t.MaxFailures
s.EnforcingConsecutive5Xx = uint32FromPointerToUint32(t.EnforcingConsecutive5xx)
}
func PeeringMeshConfigToStructs(s *PeeringMeshConfig, t *structs.PeeringMeshConfig) {
if s == nil {
return
@ -564,6 +656,76 @@ func RingHashConfigFromStructs(t *structs.RingHashConfig, s *RingHashConfig) {
s.MinimumRingSize = t.MinimumRingSize
s.MaximumRingSize = t.MaximumRingSize
}
func ServiceDefaultsToStructs(s *ServiceDefaults, t *structs.ServiceConfigEntry) {
if s == nil {
return
}
t.Protocol = s.Protocol
t.Mode = proxyModeToStructs(s.Mode)
if s.TransparentProxy != nil {
TransparentProxyConfigToStructs(s.TransparentProxy, &t.TransparentProxy)
}
if s.MeshGateway != nil {
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
}
if s.Expose != nil {
ExposeConfigToStructs(s.Expose, &t.Expose)
}
t.ExternalSNI = s.ExternalSNI
if s.UpstreamConfig != nil {
var x structs.UpstreamConfiguration
UpstreamConfigurationToStructs(s.UpstreamConfig, &x)
t.UpstreamConfig = &x
}
if s.Destination != nil {
var x structs.DestinationConfig
DestinationConfigToStructs(s.Destination, &x)
t.Destination = &x
}
t.MaxInboundConnections = int(s.MaxInboundConnections)
t.LocalConnectTimeoutMs = int(s.LocalConnectTimeoutMs)
t.LocalRequestTimeoutMs = int(s.LocalRequestTimeoutMs)
t.BalanceInboundConnections = s.BalanceInboundConnections
t.Meta = s.Meta
}
func ServiceDefaultsFromStructs(t *structs.ServiceConfigEntry, s *ServiceDefaults) {
if s == nil {
return
}
s.Protocol = t.Protocol
s.Mode = proxyModeFromStructs(t.Mode)
{
var x TransparentProxyConfig
TransparentProxyConfigFromStructs(&t.TransparentProxy, &x)
s.TransparentProxy = &x
}
{
var x MeshGatewayConfig
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
s.MeshGateway = &x
}
{
var x ExposeConfig
ExposeConfigFromStructs(&t.Expose, &x)
s.Expose = &x
}
s.ExternalSNI = t.ExternalSNI
if t.UpstreamConfig != nil {
var x UpstreamConfiguration
UpstreamConfigurationFromStructs(t.UpstreamConfig, &x)
s.UpstreamConfig = &x
}
if t.Destination != nil {
var x DestinationConfig
DestinationConfigFromStructs(t.Destination, &x)
s.Destination = &x
}
s.MaxInboundConnections = int32(t.MaxInboundConnections)
s.LocalConnectTimeoutMs = int32(t.LocalConnectTimeoutMs)
s.LocalRequestTimeoutMs = int32(t.LocalRequestTimeoutMs)
s.BalanceInboundConnections = t.BalanceInboundConnections
s.Meta = t.Meta
}
func ServiceIntentionsToStructs(s *ServiceIntentions, t *structs.ServiceIntentionsConfigEntry) {
if s == nil {
return
@ -822,6 +984,20 @@ func SourceIntentionFromStructs(t *structs.SourceIntention, s *SourceIntention)
s.EnterpriseMeta = enterpriseMetaFromStructs(t.EnterpriseMeta)
s.Peer = t.Peer
}
func TransparentProxyConfigToStructs(s *TransparentProxyConfig, t *structs.TransparentProxyConfig) {
if s == nil {
return
}
t.OutboundListenerPort = int(s.OutboundListenerPort)
t.DialedDirectly = s.DialedDirectly
}
func TransparentProxyConfigFromStructs(t *structs.TransparentProxyConfig, s *TransparentProxyConfig) {
if s == nil {
return
}
s.OutboundListenerPort = int32(t.OutboundListenerPort)
s.DialedDirectly = t.DialedDirectly
}
func TransparentProxyMeshConfigToStructs(s *TransparentProxyMeshConfig, t *structs.TransparentProxyMeshConfig) {
if s == nil {
return
@ -834,3 +1010,111 @@ func TransparentProxyMeshConfigFromStructs(t *structs.TransparentProxyMeshConfig
}
s.MeshDestinationsOnly = t.MeshDestinationsOnly
}
func UpstreamConfigToStructs(s *UpstreamConfig, t *structs.UpstreamConfig) {
if s == nil {
return
}
t.Name = s.Name
t.EnterpriseMeta = enterpriseMetaToStructs(s.EnterpriseMeta)
t.EnvoyListenerJSON = s.EnvoyListenerJSON
t.EnvoyClusterJSON = s.EnvoyClusterJSON
t.Protocol = s.Protocol
t.ConnectTimeoutMs = int(s.ConnectTimeoutMs)
if s.Limits != nil {
var x structs.UpstreamLimits
UpstreamLimitsToStructs(s.Limits, &x)
t.Limits = &x
}
if s.PassiveHealthCheck != nil {
var x structs.PassiveHealthCheck
PassiveHealthCheckToStructs(s.PassiveHealthCheck, &x)
t.PassiveHealthCheck = &x
}
if s.MeshGateway != nil {
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
}
t.BalanceOutboundConnections = s.BalanceOutboundConnections
}
func UpstreamConfigFromStructs(t *structs.UpstreamConfig, s *UpstreamConfig) {
if s == nil {
return
}
s.Name = t.Name
s.EnterpriseMeta = enterpriseMetaFromStructs(t.EnterpriseMeta)
s.EnvoyListenerJSON = t.EnvoyListenerJSON
s.EnvoyClusterJSON = t.EnvoyClusterJSON
s.Protocol = t.Protocol
s.ConnectTimeoutMs = int32(t.ConnectTimeoutMs)
if t.Limits != nil {
var x UpstreamLimits
UpstreamLimitsFromStructs(t.Limits, &x)
s.Limits = &x
}
if t.PassiveHealthCheck != nil {
var x PassiveHealthCheck
PassiveHealthCheckFromStructs(t.PassiveHealthCheck, &x)
s.PassiveHealthCheck = &x
}
{
var x MeshGatewayConfig
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
s.MeshGateway = &x
}
s.BalanceOutboundConnections = t.BalanceOutboundConnections
}
func UpstreamConfigurationToStructs(s *UpstreamConfiguration, t *structs.UpstreamConfiguration) {
if s == nil {
return
}
{
t.Overrides = make([]*structs.UpstreamConfig, len(s.Overrides))
for i := range s.Overrides {
if s.Overrides[i] != nil {
var x structs.UpstreamConfig
UpstreamConfigToStructs(s.Overrides[i], &x)
t.Overrides[i] = &x
}
}
}
if s.Defaults != nil {
var x structs.UpstreamConfig
UpstreamConfigToStructs(s.Defaults, &x)
t.Defaults = &x
}
}
func UpstreamConfigurationFromStructs(t *structs.UpstreamConfiguration, s *UpstreamConfiguration) {
if s == nil {
return
}
{
s.Overrides = make([]*UpstreamConfig, len(t.Overrides))
for i := range t.Overrides {
if t.Overrides[i] != nil {
var x UpstreamConfig
UpstreamConfigFromStructs(t.Overrides[i], &x)
s.Overrides[i] = &x
}
}
}
if t.Defaults != nil {
var x UpstreamConfig
UpstreamConfigFromStructs(t.Defaults, &x)
s.Defaults = &x
}
}
func UpstreamLimitsToStructs(s *UpstreamLimits, t *structs.UpstreamLimits) {
if s == nil {
return
}
t.MaxConnections = pointerToIntFromInt32(s.MaxConnections)
t.MaxPendingRequests = pointerToIntFromInt32(s.MaxPendingRequests)
t.MaxConcurrentRequests = pointerToIntFromInt32(s.MaxConcurrentRequests)
}
func UpstreamLimitsFromStructs(t *structs.UpstreamLimits, s *UpstreamLimits) {
if s == nil {
return
}
s.MaxConnections = int32FromPointerToInt(t.MaxConnections)
s.MaxPendingRequests = int32FromPointerToInt(t.MaxPendingRequests)
s.MaxConcurrentRequests = int32FromPointerToInt(t.MaxConcurrentRequests)
}

View File

@ -5,7 +5,7 @@ import (
"time"
"github.com/golang/protobuf/ptypes/timestamp"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/agent/structs"
@ -45,6 +45,14 @@ func ConfigEntryToStructs(s *ConfigEntry) structs.ConfigEntry {
pbcommon.RaftIndexToStructs(s.RaftIndex, &target.RaftIndex)
pbcommon.EnterpriseMetaToStructs(s.EnterpriseMeta, &target.EnterpriseMeta)
return &target
case Kind_KindServiceDefaults:
var target structs.ServiceConfigEntry
target.Name = s.Name
ServiceDefaultsToStructs(s.GetServiceDefaults(), &target)
pbcommon.RaftIndexToStructs(s.RaftIndex, &target.RaftIndex)
pbcommon.EnterpriseMetaToStructs(s.EnterpriseMeta, &target.EnterpriseMeta)
return &target
default:
panic(fmt.Sprintf("unable to convert ConfigEntry of kind %s to structs", s.Kind))
}
@ -93,6 +101,14 @@ func ConfigEntryFromStructs(s structs.ConfigEntry) *ConfigEntry {
configEntry.Entry = &ConfigEntry_ServiceIntentions{
ServiceIntentions: &serviceIntentions,
}
case *structs.ServiceConfigEntry:
var serviceDefaults ServiceDefaults
ServiceDefaultsFromStructs(v, &serviceDefaults)
configEntry.Kind = Kind_KindServiceDefaults
configEntry.Entry = &ConfigEntry_ServiceDefaults{
ServiceDefaults: &serviceDefaults,
}
default:
panic(fmt.Sprintf("unable to convert %T to proto", s))
}
@ -170,3 +186,83 @@ func intentionSourceTypeFromStructs(structs.IntentionSourceType) IntentionSource
func intentionSourceTypeToStructs(IntentionSourceType) structs.IntentionSourceType {
return structs.IntentionSourceConsul
}
func pointerToIntFromInt32(i32 int32) *int {
i := int(i32)
return &i
}
func int32FromPointerToInt(i *int) int32 {
if i != nil {
return int32(*i)
}
return 0
}
func pointerToUint32FromUint32(ui32 uint32) *uint32 {
i := ui32
return &i
}
func uint32FromPointerToUint32(i *uint32) uint32 {
if i != nil {
return *i
}
return 0
}
func proxyModeFromStructs(a structs.ProxyMode) ProxyMode {
switch a {
case structs.ProxyModeDefault:
return ProxyMode_ProxyModeDefault
case structs.ProxyModeTransparent:
return ProxyMode_ProxyModeTransparent
case structs.ProxyModeDirect:
return ProxyMode_ProxyModeDirect
default:
return ProxyMode_ProxyModeDefault
}
}
func proxyModeToStructs(a ProxyMode) structs.ProxyMode {
switch a {
case ProxyMode_ProxyModeDefault:
return structs.ProxyModeDefault
case ProxyMode_ProxyModeTransparent:
return structs.ProxyModeTransparent
case ProxyMode_ProxyModeDirect:
return structs.ProxyModeDirect
default:
return structs.ProxyModeDefault
}
}
func meshGatewayModeFromStructs(a structs.MeshGatewayMode) MeshGatewayMode {
switch a {
case structs.MeshGatewayModeDefault:
return MeshGatewayMode_MeshGatewayModeDefault
case structs.MeshGatewayModeNone:
return MeshGatewayMode_MeshGatewayModeNone
case structs.MeshGatewayModeLocal:
return MeshGatewayMode_MeshGatewayModeLocal
case structs.MeshGatewayModeRemote:
return MeshGatewayMode_MeshGatewayModeRemote
default:
return MeshGatewayMode_MeshGatewayModeDefault
}
}
func meshGatewayModeToStructs(a MeshGatewayMode) structs.MeshGatewayMode {
switch a {
case MeshGatewayMode_MeshGatewayModeDefault:
return structs.MeshGatewayModeDefault
case MeshGatewayMode_MeshGatewayModeNone:
return structs.MeshGatewayModeNone
case MeshGatewayMode_MeshGatewayModeLocal:
return structs.MeshGatewayModeLocal
case MeshGatewayMode_MeshGatewayModeRemote:
return structs.MeshGatewayModeRemote
default:
return structs.MeshGatewayModeDefault
}
}

View File

@ -306,3 +306,103 @@ func (msg *IntentionHTTPHeaderPermission) MarshalBinary() ([]byte, error) {
func (msg *IntentionHTTPHeaderPermission) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *ServiceDefaults) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *ServiceDefaults) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *TransparentProxyConfig) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *TransparentProxyConfig) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *MeshGatewayConfig) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *MeshGatewayConfig) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *ExposeConfig) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *ExposeConfig) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *ExposePath) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *ExposePath) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *UpstreamConfiguration) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *UpstreamConfiguration) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *UpstreamConfig) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *UpstreamConfig) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *UpstreamLimits) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *UpstreamLimits) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *PassiveHealthCheck) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *PassiveHealthCheck) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}
// MarshalBinary implements encoding.BinaryMarshaler
func (msg *DestinationConfig) MarshalBinary() ([]byte, error) {
return proto.Marshal(msg)
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler
func (msg *DestinationConfig) UnmarshalBinary(b []byte) error {
return proto.Unmarshal(b, msg)
}

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ enum Kind {
KindServiceResolver = 2;
KindIngressGateway = 3;
KindServiceIntentions = 4;
KindServiceDefaults = 5;
}
message ConfigEntry {
@ -26,6 +27,7 @@ message ConfigEntry {
ServiceResolver ServiceResolver = 6;
IngressGateway IngressGateway = 7;
ServiceIntentions ServiceIntentions = 8;
ServiceDefaults ServiceDefaults = 9;
}
}
@ -404,3 +406,156 @@ message IntentionHTTPHeaderPermission {
string Regex = 6;
bool Invert = 7;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.ServiceConfigEntry
// output=config_entry.gen.go
// name=Structs
// ignore-fields=Kind,Name,RaftIndex,EnterpriseMeta
message ServiceDefaults {
string Protocol = 1;
// mog: func-to=proxyModeToStructs func-from=proxyModeFromStructs
ProxyMode Mode = 2;
TransparentProxyConfig TransparentProxy = 3;
MeshGatewayConfig MeshGateway = 4;
ExposeConfig Expose = 5;
string ExternalSNI = 6;
UpstreamConfiguration UpstreamConfig = 7;
DestinationConfig Destination = 8;
// mog: func-to=int func-from=int32
int32 MaxInboundConnections = 9;
// mog: func-to=int func-from=int32
int32 LocalConnectTimeoutMs = 10;
// mog: func-to=int func-from=int32
int32 LocalRequestTimeoutMs = 11;
string BalanceInboundConnections = 12;
map<string, string> Meta = 13;
}
enum ProxyMode {
ProxyModeDefault = 0;
ProxyModeTransparent = 1;
ProxyModeDirect = 2;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.TransparentProxyConfig
// output=config_entry.gen.go
// name=Structs
message TransparentProxyConfig {
// mog: func-to=int func-from=int32
int32 OutboundListenerPort = 1;
bool DialedDirectly = 2;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.MeshGatewayConfig
// output=config_entry.gen.go
// name=Structs
message MeshGatewayConfig {
// mog: func-to=meshGatewayModeToStructs func-from=meshGatewayModeFromStructs
MeshGatewayMode Mode = 1;
}
enum MeshGatewayMode {
MeshGatewayModeDefault = 0;
MeshGatewayModeNone = 1;
MeshGatewayModeLocal = 2;
MeshGatewayModeRemote = 3;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.ExposeConfig
// output=config_entry.gen.go
// name=Structs
message ExposeConfig {
bool Checks = 1;
repeated ExposePath Paths = 2;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.ExposePath
// output=config_entry.gen.go
// name=Structs
message ExposePath {
// mog: func-to=int func-from=int32
int32 ListenerPort = 1;
string Path = 2;
// mog: func-to=int func-from=int32
int32 LocalPathPort = 3;
string Protocol = 4;
bool ParsedFromCheck = 5;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.UpstreamConfiguration
// output=config_entry.gen.go
// name=Structs
message UpstreamConfiguration {
repeated UpstreamConfig Overrides = 1;
UpstreamConfig Defaults = 2;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.UpstreamConfig
// output=config_entry.gen.go
// name=Structs
message UpstreamConfig {
string Name = 1;
// mog: func-to=enterpriseMetaToStructs func-from=enterpriseMetaFromStructs
common.EnterpriseMeta EnterpriseMeta = 2;
string EnvoyListenerJSON = 3;
string EnvoyClusterJSON = 4;
string Protocol = 5;
// mog: func-to=int func-from=int32
int32 ConnectTimeoutMs = 6;
UpstreamLimits Limits = 7;
PassiveHealthCheck PassiveHealthCheck = 8;
MeshGatewayConfig MeshGateway = 9;
string BalanceOutboundConnections = 10;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.UpstreamLimits
// output=config_entry.gen.go
// name=Structs
message UpstreamLimits {
// mog: func-to=pointerToIntFromInt32 func-from=int32FromPointerToInt
int32 MaxConnections = 1;
// mog: func-to=pointerToIntFromInt32 func-from=int32FromPointerToInt
int32 MaxPendingRequests = 2;
// mog: func-to=pointerToIntFromInt32 func-from=int32FromPointerToInt
int32 MaxConcurrentRequests = 3;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.PassiveHealthCheck
// output=config_entry.gen.go
// name=Structs
message PassiveHealthCheck {
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
google.protobuf.Duration Interval = 1;
uint32 MaxFailures = 2;
// mog: target=EnforcingConsecutive5xx func-to=pointerToUint32FromUint32 func-from=uint32FromPointerToUint32
uint32 EnforcingConsecutive5xx = 3;
}
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.DestinationConfig
// output=config_entry.gen.go
// name=Structs
message DestinationConfig {
repeated string Addresses = 1;
// mog: func-to=int func-from=int32
int32 Port = 2;
}

View File

@ -46,7 +46,7 @@ const (
Topic_MeshConfig Topic = 3
// ServiceResolver topic contains events for changes to a service resolver.
Topic_ServiceResolver Topic = 4
// ServiceResolver topic contains events for changes to an ingress gateway.
// IngressGateway topic contains events for changes to an ingress gateway.
Topic_IngressGateway Topic = 5
// ServiceIntentions topic contains events for changes to service intentions.
Topic_ServiceIntentions Topic = 6
@ -56,6 +56,8 @@ const (
//
// Note: WildcardSubject is the only supported Subject on this topic.
Topic_ServiceList Topic = 7
// ServiceDefaults topic contains events for changes to service-defaults.
Topic_ServiceDefaults Topic = 8
)
// Enum value maps for Topic.
@ -69,6 +71,7 @@ var (
5: "IngressGateway",
6: "ServiceIntentions",
7: "ServiceList",
8: "ServiceDefaults",
}
Topic_value = map[string]int32{
"Unknown": 0,
@ -79,6 +82,7 @@ var (
"IngressGateway": 5,
"ServiceIntentions": 6,
"ServiceList": 7,
"ServiceDefaults": 8,
}
)
@ -955,7 +959,7 @@ var file_proto_pbsubscribe_subscribe_proto_rawDesc = []byte{
0x45, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x0e,
0x45, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x1a,
0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x2a, 0xa2, 0x01, 0x0a, 0x05, 0x54,
0x52, 0x08, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x2a, 0xb7, 0x01, 0x0a, 0x05, 0x54,
0x6f, 0x70, 0x69, 0x63, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10,
0x00, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48, 0x65, 0x61, 0x6c,
0x74, 0x68, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48,
@ -965,26 +969,27 @@ var file_proto_pbsubscribe_subscribe_proto_rawDesc = []byte{
0x72, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x47, 0x61,
0x74, 0x65, 0x77, 0x61, 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x06, 0x12, 0x0f,
0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x07, 0x2a,
0x29, 0x0a, 0x09, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x4f, 0x70, 0x12, 0x0c, 0x0a, 0x08,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65,
0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x10, 0x01, 0x32, 0x59, 0x0a, 0x17, 0x53, 0x74,
0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x12, 0x1b, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x2e, 0x53,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x10, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x2e, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x22, 0x00, 0x30, 0x01, 0x42, 0x92, 0x01, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x75,
0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x42, 0x0e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f,
0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x73,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02,
0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xca, 0x02, 0x09, 0x53, 0x75, 0x62,
0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xe2, 0x02, 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x07, 0x12,
0x13, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c,
0x74, 0x73, 0x10, 0x08, 0x2a, 0x29, 0x0a, 0x09, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x4f,
0x70, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x10, 0x00, 0x12,
0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x10, 0x01, 0x32,
0x59, 0x0a, 0x17, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x75,
0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x09, 0x53, 0x75,
0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1b, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65,
0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x30, 0x01, 0x42, 0x92, 0x01, 0x0a, 0x0d, 0x63,
0x6f, 0x6d, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x42, 0x0e, 0x53, 0x75,
0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2d,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69,
0x63, 0x6f, 0x72, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2f, 0x70, 0x62, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xa2, 0x02, 0x03,
0x53, 0x58, 0x58, 0xaa, 0x02, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xca,
0x02, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0xe2, 0x02, 0x15, 0x53, 0x75,
0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -58,7 +58,7 @@ enum Topic {
// ServiceResolver topic contains events for changes to a service resolver.
ServiceResolver = 4;
// ServiceResolver topic contains events for changes to an ingress gateway.
// IngressGateway topic contains events for changes to an ingress gateway.
IngressGateway = 5;
// ServiceIntentions topic contains events for changes to service intentions.
@ -70,6 +70,9 @@ enum Topic {
//
// Note: WildcardSubject is the only supported Subject on this topic.
ServiceList = 7;
// ServiceDefaults topic contains events for changes to service-defaults.
ServiceDefaults = 8;
}
message NamedSubject {