Skip to content

Commit

Permalink
Rename "cluster" config entry to "mesh" (#10127)
Browse files Browse the repository at this point in the history
This config entry is being renamed primarily because in k8s the name
cluster could be confusing given that the config entry applies across
federated datacenters.

Additionally, this config entry will only apply to Consul as a service
mesh, so the more generic "cluster" name is not needed.
  • Loading branch information
freddygv authored Apr 28, 2021
1 parent e19aef4 commit 078c404
Show file tree
Hide file tree
Showing 21 changed files with 164 additions and 159 deletions.
3 changes: 3 additions & 0 deletions .changelog/10127.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
connect: rename cluster config entry to mesh.
```
32 changes: 16 additions & 16 deletions agent/config/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4156,8 +4156,8 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
"config_entries": {
"bootstrap": [
{
"kind": "cluster",
"name": "cluster",
"kind": "mesh",
"name": "mesh",
"meta" : {
"foo": "bar",
"gir": "zim"
Expand All @@ -4173,8 +4173,8 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
hcl: []string{`
config_entries {
bootstrap {
kind = "cluster"
name = "cluster"
kind = "mesh"
name = "mesh"
meta {
"foo" = "bar"
"gir" = "zim"
Expand All @@ -4189,15 +4189,15 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
expected: func(rt *RuntimeConfig) {
rt.DataDir = dataDir
rt.ConfigEntryBootstrap = []structs.ConfigEntry{
&structs.ClusterConfigEntry{
Kind: "cluster",
Name: "cluster",
&structs.MeshConfigEntry{
Kind: structs.MeshConfig,
Name: structs.MeshConfigMesh,
Meta: map[string]string{
"foo": "bar",
"gir": "zim",
},
EnterpriseMeta: *defaultEntMeta,
TransparentProxy: structs.TransparentProxyClusterConfig{
TransparentProxy: structs.TransparentProxyMeshConfig{
CatalogDestinationsOnly: true,
},
},
Expand All @@ -4211,8 +4211,8 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
"config_entries": {
"bootstrap": [
{
"Kind": "cluster",
"Name": "cluster",
"Kind": "mesh",
"Name": "mesh",
"Meta" : {
"foo": "bar",
"gir": "zim"
Expand All @@ -4228,8 +4228,8 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
hcl: []string{`
config_entries {
bootstrap {
Kind = "cluster"
Name = "cluster"
Kind = "mesh"
Name = "mesh"
Meta {
"foo" = "bar"
"gir" = "zim"
Expand All @@ -4244,15 +4244,15 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
expected: func(rt *RuntimeConfig) {
rt.DataDir = dataDir
rt.ConfigEntryBootstrap = []structs.ConfigEntry{
&structs.ClusterConfigEntry{
Kind: "cluster",
Name: "cluster",
&structs.MeshConfigEntry{
Kind: structs.MeshConfig,
Name: structs.MeshConfigMesh,
Meta: map[string]string{
"foo": "bar",
"gir": "zim",
},
EnterpriseMeta: *defaultEntMeta,
TransparentProxy: structs.TransparentProxyClusterConfig{
TransparentProxy: structs.TransparentProxyMeshConfig{
CatalogDestinationsOnly: true,
},
},
Expand Down
18 changes: 9 additions & 9 deletions agent/consul/fsm/snapshot_oss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,15 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
}
require.NoError(t, fsm.state.EnsureConfigEntry(26, serviceIxn))

// cluster config entry
clusterConfig := &structs.ClusterConfigEntry{
Kind: structs.ClusterConfig,
Name: structs.ClusterConfigCluster,
TransparentProxy: structs.TransparentProxyClusterConfig{
// mesh config entry
meshConfig := &structs.MeshConfigEntry{
Kind: structs.MeshConfig,
Name: structs.MeshConfigMesh,
TransparentProxy: structs.TransparentProxyMeshConfig{
CatalogDestinationsOnly: true,
},
}
require.NoError(t, fsm.state.EnsureConfigEntry(27, clusterConfig))
require.NoError(t, fsm.state.EnsureConfigEntry(27, meshConfig))

// Snapshot
snap, err := fsm.Snapshot()
Expand Down Expand Up @@ -710,10 +710,10 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
require.NoError(t, err)
require.Equal(t, serviceIxn, serviceIxnEntry)

// Verify cluster config entry is restored
_, clusterConfigEntry, err := fsm2.state.ConfigEntry(nil, structs.ClusterConfig, structs.ClusterConfigCluster, structs.DefaultEnterpriseMeta())
// Verify mesh config entry is restored
_, meshConfigEntry, err := fsm2.state.ConfigEntry(nil, structs.MeshConfig, structs.MeshConfigMesh, structs.DefaultEnterpriseMeta())
require.NoError(t, err)
require.Equal(t, clusterConfig, clusterConfigEntry)
require.Equal(t, meshConfig, meshConfigEntry)

// Snapshot
snap, err = fsm2.Snapshot()
Expand Down
2 changes: 1 addition & 1 deletion agent/consul/state/config_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func validateProposedConfigEntryInGraph(
return err
}
case structs.ServiceIntentions:
case structs.ClusterConfig:
case structs.MeshConfig:
default:
return fmt.Errorf("unhandled kind %q during validation of %q", kind, name)
}
Expand Down
8 changes: 4 additions & 4 deletions agent/proxycfg/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type configSnapshotConnectProxy struct {
Intentions structs.Intentions
IntentionsSet bool

ClusterConfig *structs.ClusterConfigEntry
ClusterConfigSet bool
MeshConfig *structs.MeshConfigEntry
MeshConfigSet bool
}

func (c *configSnapshotConnectProxy) IsEmpty() bool {
Expand All @@ -80,7 +80,7 @@ func (c *configSnapshotConnectProxy) IsEmpty() bool {
len(c.WatchedServiceChecks) == 0 &&
len(c.PreparedQueryEndpoints) == 0 &&
len(c.UpstreamConfig) == 0 &&
!c.ClusterConfigSet
!c.MeshConfigSet
}

type configSnapshotTerminatingGateway struct {
Expand Down Expand Up @@ -360,7 +360,7 @@ type ConfigSnapshot struct {
func (s *ConfigSnapshot) Valid() bool {
switch s.Kind {
case structs.ServiceKindConnectProxy:
if s.Proxy.Mode == structs.ProxyModeTransparent && !s.ConnectProxy.ClusterConfigSet {
if s.Proxy.Mode == structs.ProxyModeTransparent && !s.ConnectProxy.MeshConfigSet {
return false
}
return s.Roots != nil &&
Expand Down
18 changes: 9 additions & 9 deletions agent/proxycfg/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
serviceResolverIDPrefix = "service-resolver:"
serviceIntentionsIDPrefix = "service-intentions:"
intentionUpstreamsID = "intention-upstreams"
clusterConfigEntryID = "cluster-config"
meshConfigEntryID = "mesh"
svcChecksWatchIDPrefix = cachetype.ServiceHTTPChecksName + ":"
serviceIDPrefix = string(structs.UpstreamDestTypeService) + ":"
preparedQueryIDPrefix = string(structs.UpstreamDestTypePreparedQuery) + ":"
Expand Down Expand Up @@ -318,12 +318,12 @@ func (s *state) initWatchesConnectProxy(snap *ConfigSnapshot) error {
}

err = s.cache.Notify(s.ctx, cachetype.ConfigEntryName, &structs.ConfigEntryQuery{
Kind: structs.ClusterConfig,
Name: structs.ClusterConfigCluster,
Kind: structs.MeshConfig,
Name: structs.MeshConfigMesh,
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
}, clusterConfigEntryID, s.ch)
}, meshConfigEntryID, s.ch)
if err != nil {
return err
}
Expand Down Expand Up @@ -887,22 +887,22 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
svcID := structs.ServiceIDFromString(strings.TrimPrefix(u.CorrelationID, svcChecksWatchIDPrefix))
snap.ConnectProxy.WatchedServiceChecks[svcID] = resp

case u.CorrelationID == clusterConfigEntryID:
case u.CorrelationID == meshConfigEntryID:
resp, ok := u.Result.(*structs.ConfigEntryResponse)
if !ok {
return fmt.Errorf("invalid type for response: %T", u.Result)
}

if resp.Entry != nil {
clusterConf, ok := resp.Entry.(*structs.ClusterConfigEntry)
meshConf, ok := resp.Entry.(*structs.MeshConfigEntry)
if !ok {
return fmt.Errorf("invalid type for config entry: %T", resp.Entry)
}
snap.ConnectProxy.ClusterConfig = clusterConf
snap.ConnectProxy.MeshConfig = meshConf
} else {
snap.ConnectProxy.ClusterConfig = nil
snap.ConnectProxy.MeshConfig = nil
}
snap.ConnectProxy.ClusterConfigSet = true
snap.ConnectProxy.MeshConfigSet = true

default:
return s.handleUpdateUpstreams(u, &snap.ConnectProxy.ConfigSnapshotUpstreams)
Expand Down
38 changes: 19 additions & 19 deletions agent/proxycfg/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ func genVerifyDiscoveryChainWatch(expected *structs.DiscoveryChainRequest) verif
}
}

func genVerifyClusterConfigWatch(expectedDatacenter string) verifyWatchRequest {
func genVerifyMeshConfigWatch(expectedDatacenter string) verifyWatchRequest {
return func(t testing.TB, cacheType string, request cache.Request) {
require.Equal(t, cachetype.ConfigEntryName, cacheType)

reqReal, ok := request.(*structs.ConfigEntryQuery)
require.True(t, ok)
require.Equal(t, expectedDatacenter, reqReal.Datacenter)
require.Equal(t, structs.ClusterConfigCluster, reqReal.Name)
require.Equal(t, structs.ClusterConfig, reqReal.Kind)
require.Equal(t, structs.MeshConfigMesh, reqReal.Name)
require.Equal(t, structs.MeshConfig, reqReal.Kind)
}
}

Expand Down Expand Up @@ -1554,9 +1554,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
rootsWatchID: genVerifyRootsWatch("dc1"),
intentionUpstreamsID: genVerifyServiceSpecificRequest(intentionUpstreamsID,
"api", "", "dc1", false),
leafWatchID: genVerifyLeafWatch("api", "dc1"),
intentionsWatchID: genVerifyIntentionWatch("api", "dc1"),
clusterConfigEntryID: genVerifyClusterConfigWatch("dc1"),
leafWatchID: genVerifyLeafWatch("api", "dc1"),
intentionsWatchID: genVerifyIntentionWatch("api", "dc1"),
meshConfigEntryID: genVerifyMeshConfigWatch("dc1"),
},
verifySnapshot: func(t testing.TB, snap *ConfigSnapshot) {
require.False(t, snap.Valid(), "proxy without roots/leaf/intentions is not valid")
Expand Down Expand Up @@ -1588,7 +1588,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
Err: nil,
},
{
CorrelationID: clusterConfigEntryID,
CorrelationID: meshConfigEntryID,
Result: &structs.ConfigEntryResponse{
Entry: nil, // no explicit config
},
Expand All @@ -1603,8 +1603,8 @@ func TestState_WatchesAndUpdates(t *testing.T) {
require.True(t, snap.MeshGateway.IsEmpty())
require.True(t, snap.IngressGateway.IsEmpty())
require.True(t, snap.TerminatingGateway.IsEmpty())
require.True(t, snap.ConnectProxy.ClusterConfigSet)
require.Nil(t, snap.ConnectProxy.ClusterConfig)
require.True(t, snap.ConnectProxy.MeshConfigSet)
require.Nil(t, snap.ConnectProxy.MeshConfig)
},
},
},
Expand Down Expand Up @@ -1639,9 +1639,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
rootsWatchID: genVerifyRootsWatch("dc1"),
intentionUpstreamsID: genVerifyServiceSpecificRequest(intentionUpstreamsID,
"api", "", "dc1", false),
leafWatchID: genVerifyLeafWatch("api", "dc1"),
intentionsWatchID: genVerifyIntentionWatch("api", "dc1"),
clusterConfigEntryID: genVerifyClusterConfigWatch("dc1"),
leafWatchID: genVerifyLeafWatch("api", "dc1"),
intentionsWatchID: genVerifyIntentionWatch("api", "dc1"),
meshConfigEntryID: genVerifyMeshConfigWatch("dc1"),
},
verifySnapshot: func(t testing.TB, snap *ConfigSnapshot) {
require.False(t, snap.Valid(), "proxy without roots/leaf/intentions is not valid")
Expand Down Expand Up @@ -1671,12 +1671,12 @@ func TestState_WatchesAndUpdates(t *testing.T) {
Err: nil,
},
{
CorrelationID: clusterConfigEntryID,
CorrelationID: meshConfigEntryID,
Result: &structs.ConfigEntryResponse{
Entry: &structs.ClusterConfigEntry{
Kind: structs.ClusterConfig,
Name: structs.ClusterConfigCluster,
TransparentProxy: structs.TransparentProxyClusterConfig{},
Entry: &structs.MeshConfigEntry{
Kind: structs.MeshConfig,
Name: structs.MeshConfigMesh,
TransparentProxy: structs.TransparentProxyMeshConfig{},
},
},
Err: nil,
Expand All @@ -1690,8 +1690,8 @@ func TestState_WatchesAndUpdates(t *testing.T) {
require.True(t, snap.MeshGateway.IsEmpty())
require.True(t, snap.IngressGateway.IsEmpty())
require.True(t, snap.TerminatingGateway.IsEmpty())
require.True(t, snap.ConnectProxy.ClusterConfigSet)
require.NotNil(t, snap.ConnectProxy.ClusterConfig)
require.True(t, snap.ConnectProxy.MeshConfigSet)
require.NotNil(t, snap.ConnectProxy.MeshConfig)
},
},
// Receiving an intention should lead to spinning up a discovery chain watch
Expand Down
12 changes: 6 additions & 6 deletions agent/structs/config_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const (
IngressGateway string = "ingress-gateway"
TerminatingGateway string = "terminating-gateway"
ServiceIntentions string = "service-intentions"
ClusterConfig string = "cluster"
MeshConfig string = "mesh"

ProxyConfigGlobal string = "global"
ClusterConfigCluster string = "cluster"
ProxyConfigGlobal string = "global"
MeshConfigMesh string = "mesh"

DefaultServiceProtocol = "tcp"
)
Expand All @@ -43,7 +43,7 @@ var AllConfigEntryKinds = []string{
IngressGateway,
TerminatingGateway,
ServiceIntentions,
ClusterConfig,
MeshConfig,
}

// ConfigEntry is the interface for centralized configuration stored in Raft.
Expand Down Expand Up @@ -528,8 +528,8 @@ func MakeConfigEntry(kind, name string) (ConfigEntry, error) {
return &TerminatingGatewayConfigEntry{Name: name}, nil
case ServiceIntentions:
return &ServiceIntentionsConfigEntry{Name: name}, nil
case ClusterConfig:
return &ClusterConfigEntry{Name: name}, nil
case MeshConfig:
return &MeshConfigEntry{Name: name}, nil
default:
return nil, fmt.Errorf("invalid config entry kind: %s", kind)
}
Expand Down
Loading

0 comments on commit 078c404

Please sign in to comment.