Skip to content

Commit e446b5c

Browse files
authored
chore(active-active): Remove RegionInformation from cluster group metadata (cadence-workflow#7275)
<!-- Describe what has changed in this PR --> **What changed?** Remove RegionInformation from cluster group metadata <!-- Tell your future self why have you made these changes --> **Why?** There was a design decision change that removes the region concept. <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> **How did you test it?** unit tests & replication simulation tests <!-- Assuming the worst case, what can be broken when deploying this change to production? --> **Potential risks** <!-- Is it notable for release? e.g. schema updates, configuration or data migration required? If so, please mention it, and also update CHANGELOG.md --> **Release notes** Active-Active (experimental) Breaking (experimental only): clusterGroupMetadata.regions removed. Remove the regions block from your config or the service will fail to start with yaml: unmarshal errors: field regions not found in type config.ClusterGroupMetadata. <!-- Is there any documentation updates should be made for config, https://cadenceworkflow.io/docs/operation-guide/setup/ ? If so, please open an PR in https://github.com/cadence-workflow/cadence-docs --> **Documentation Changes**
1 parent f574b6d commit e446b5c

File tree

8 files changed

+0
-189
lines changed

8 files changed

+0
-189
lines changed

common/activecluster/manager_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,6 @@ func TestLookupNewWorkflow(t *testing.T) {
200200
Region: "us-east",
201201
},
202202
},
203-
Regions: map[string]config.RegionInformation{
204-
"us-west": {
205-
InitialFailoverVersion: 0,
206-
},
207-
"us-east": {
208-
InitialFailoverVersion: 2,
209-
},
210-
},
211203
FailoverVersionIncrement: 100,
212204
CurrentClusterName: "cluster0",
213205
},
@@ -347,14 +339,6 @@ func TestLookupWorkflow(t *testing.T) {
347339
Region: "us-east",
348340
},
349341
},
350-
Regions: map[string]config.RegionInformation{
351-
"us-west": {
352-
InitialFailoverVersion: 0,
353-
},
354-
"us-east": {
355-
InitialFailoverVersion: 2,
356-
},
357-
},
358342
FailoverVersionIncrement: 100,
359343
CurrentClusterName: "cluster0",
360344
},

common/cluster/metadata.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ type (
5252
enabledClusters map[string]config.ClusterInformation
5353
// remoteClusters contains enabled and remote info
5454
remoteClusters map[string]config.ClusterInformation
55-
// regions contains all region info
56-
regions map[string]config.RegionInformation
5755
// versionToClusterName contains all initial version -> corresponding cluster name
5856
versionToClusterName map[int64]string
5957
// versionToRegionName contains all initial version -> corresponding region name
@@ -75,11 +73,6 @@ func NewMetadata(
7573
versionToClusterName[info.InitialFailoverVersion] = clusterName
7674
}
7775

78-
versionToRegionName := make(map[int64]string)
79-
for region, info := range clusterGroupMetadata.Regions {
80-
versionToRegionName[info.InitialFailoverVersion] = region
81-
}
82-
8376
// We never use disable clusters, filter them out on start
8477
enabledClusters := map[string]config.ClusterInformation{}
8578
for cluster, info := range clusterGroupMetadata.ClusterGroup {
@@ -106,9 +99,7 @@ func NewMetadata(
10699
allClusters: clusterGroupMetadata.ClusterGroup,
107100
enabledClusters: enabledClusters,
108101
remoteClusters: remoteClusters,
109-
regions: clusterGroupMetadata.Regions,
110102
versionToClusterName: versionToClusterName,
111-
versionToRegionName: versionToRegionName,
112103
useNewFailoverVersionOverride: useMinFailoverVersionOverrideConfig,
113104
}
114105

@@ -163,11 +154,6 @@ func (m Metadata) GetCurrentRegion() string {
163154
return m.currentRegion
164155
}
165156

166-
// GetAllRegionInfo return all region info
167-
func (m Metadata) GetAllRegionInfo() map[string]config.RegionInformation {
168-
return m.regions
169-
}
170-
171157
// GetAllClusterInfo return all cluster info
172158
func (m Metadata) GetAllClusterInfo() map[string]config.ClusterInformation {
173159
return m.allClusters
@@ -196,20 +182,6 @@ func (m Metadata) ClusterNameForFailoverVersion(failoverVersion int64) (string,
196182
return server, nil
197183
}
198184

199-
// RegionForFailoverVersion return the corresponding region for a given failover version
200-
func (m Metadata) RegionForFailoverVersion(failoverVersion int64) (string, error) {
201-
if failoverVersion == constants.EmptyVersion {
202-
return m.currentRegion, nil
203-
}
204-
205-
region, err := m.resolveRegion(failoverVersion)
206-
if err != nil {
207-
m.metrics.IncCounter(metrics.ClusterMetadataResolvingFailoverVersionCounter)
208-
return "", fmt.Errorf("failed to resolve failover version to a region: %v", err)
209-
}
210-
return region, nil
211-
}
212-
213185
// gets the initial failover version for a cluster / domain
214186
// along with some helpers for a migration - should it be necessary
215187
func (m Metadata) getInitialFailoverVersion(cluster string, domainName string) int64 {
@@ -259,14 +231,3 @@ func (m Metadata) resolveServerName(originalVersion int64) (string, error) {
259231
m.metrics.IncCounter(metrics.ClusterMetadataFailureToResolveCounter)
260232
return "", fmt.Errorf("could not resolve failover version: %d", originalVersion)
261233
}
262-
263-
func (m Metadata) resolveRegion(originalVersion int64) (string, error) {
264-
version := originalVersion % m.failoverVersionIncrement
265-
region, ok := m.versionToRegionName[version]
266-
if ok {
267-
return region, nil
268-
}
269-
270-
m.metrics.IncCounter(metrics.ClusterMetadataFailureToResolveCounter)
271-
return "", fmt.Errorf("could not resolve failover version to region: %d", originalVersion)
272-
}

common/cluster/metadata_test.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -784,62 +784,6 @@ func TestClusterNameForFailoverVersion(t *testing.T) {
784784
}
785785
}
786786

787-
func TestRegionForFailoverVersion(t *testing.T) {
788-
metadata := NewMetadata(
789-
config.ClusterGroupMetadata{
790-
ClusterGroup: map[string]config.ClusterInformation{
791-
"cluster0": {
792-
InitialFailoverVersion: 1,
793-
Region: "us-west",
794-
},
795-
"cluster1": {
796-
InitialFailoverVersion: 3,
797-
Region: "us-east",
798-
},
799-
},
800-
Regions: map[string]config.RegionInformation{
801-
"us-west": {
802-
InitialFailoverVersion: 0,
803-
},
804-
"us-east": {
805-
InitialFailoverVersion: 2,
806-
},
807-
},
808-
FailoverVersionIncrement: 100,
809-
CurrentClusterName: "cluster0",
810-
},
811-
func(d string) bool { return false },
812-
metrics.NewNoopMetricsClient(),
813-
log.NewNoop(),
814-
)
815-
816-
tests := []struct {
817-
name string
818-
failoverVersion int64
819-
expectedRegion string
820-
expectedErr string
821-
}{
822-
{"empty version", -24, "us-west", ""},
823-
{"exact version of us-west region", 0, "us-west", ""},
824-
{"increment version of us-west region", 200, "us-west", ""},
825-
{"exact version of us-east region", 2, "us-east", ""},
826-
{"increment version of us-east region", 202, "us-east", ""},
827-
{"not a region version", 1, "", "failed to resolve failover version to a region: could not resolve failover version to region: 1"},
828-
}
829-
830-
for _, test := range tests {
831-
t.Run(test.name, func(t *testing.T) {
832-
region, err := metadata.RegionForFailoverVersion(test.failoverVersion)
833-
if test.expectedErr == "" {
834-
assert.NoError(t, err)
835-
assert.Equal(t, test.expectedRegion, region)
836-
} else {
837-
assert.EqualError(t, err, test.expectedErr)
838-
}
839-
})
840-
}
841-
}
842-
843787
func TestServerResolution(t *testing.T) {
844788
const clusterName1 = "c1"
845789
const initialFailoverVersionC1 = 0
@@ -1020,14 +964,6 @@ func TestGetters(t *testing.T) {
1020964
Enabled: false,
1021965
},
1022966
},
1023-
Regions: map[string]config.RegionInformation{
1024-
"us-west": {
1025-
InitialFailoverVersion: 0,
1026-
},
1027-
"us-east": {
1028-
InitialFailoverVersion: 2,
1029-
},
1030-
},
1031967
FailoverVersionIncrement: 100,
1032968
CurrentClusterName: "cluster0",
1033969
PrimaryClusterName: "cluster0",
@@ -1045,16 +981,6 @@ func TestGetters(t *testing.T) {
1045981
assert.Equal(t, []string{"cluster0", "cluster1", "cluster2"}, keysOfClusterInfoMap(m.GetAllClusterInfo()))
1046982
assert.Equal(t, []string{"cluster0", "cluster1"}, keysOfClusterInfoMap(m.GetEnabledClusterInfo()))
1047983
assert.Equal(t, []string{"cluster1"}, keysOfClusterInfoMap(m.GetRemoteClusterInfo()))
1048-
assert.Equal(t, []string{"us-east", "us-west"}, keysOfRegionInfoMap(m.GetAllRegionInfo()))
1049-
}
1050-
1051-
func keysOfRegionInfoMap(m map[string]config.RegionInformation) []string {
1052-
keys := make([]string, 0, len(m))
1053-
for k := range m {
1054-
keys = append(keys, k)
1055-
}
1056-
sort.Strings(keys)
1057-
return keys
1058984
}
1059985

1060986
func keysOfClusterInfoMap(m map[string]config.ClusterInformation) []string {

common/cluster/metadata_test_utils.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ const (
3434
TestAlternativeClusterInitialFailoverVersion = int64(1)
3535
// TestDisabledClusterInitialFailoverVersion is initial failover version for disabled cluster
3636
TestDisabledClusterInitialFailoverVersion = int64(2)
37-
// TestRegion1InitialFailoverVersion is initial failover version for region1
38-
TestRegion1InitialFailoverVersion = int64(3)
39-
// TestRegion2InitialFailoverVersion is initial failover version for region2
40-
TestRegion2InitialFailoverVersion = int64(4)
4137
// TestFailoverVersionIncrement is failover version increment used for test
4238
TestFailoverVersionIncrement = int64(10)
4339
// TestCurrentClusterName is current cluster used for test
@@ -59,14 +55,6 @@ const (
5955
)
6056

6157
var (
62-
TestRegions = map[string]config.RegionInformation{
63-
TestRegion1: {
64-
InitialFailoverVersion: TestRegion1InitialFailoverVersion,
65-
},
66-
TestRegion2: {
67-
InitialFailoverVersion: TestRegion2InitialFailoverVersion,
68-
},
69-
}
7058
// TestAllClusterNames is the all cluster names used for test
7159
TestAllClusterNames = []string{TestCurrentClusterName, TestAlternativeClusterName}
7260
// TestAllClusterInfo is the same as above, just convenient for test mocking
@@ -147,7 +135,6 @@ func GetTestClusterMetadata(isPrimaryCluster bool) Metadata {
147135
PrimaryClusterName: primaryClusterName,
148136
CurrentClusterName: TestCurrentClusterName,
149137
ClusterGroup: TestAllClusterInfo,
150-
Regions: TestRegions,
151138
},
152139
func(d string) bool { return false },
153140
commonMetrics.NewNoopMetricsClient(),

common/config/cluster.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ type (
4848
// ClusterGroup contains information for each cluster within the replication group
4949
// Key is the clusterName
5050
ClusterGroup map[string]ClusterInformation `yaml:"clusterGroup"`
51-
// Regions is a map of region name to region information.
52-
// Key is the region name.
53-
// Each cluster must belong to one and only one region. Specified in clusterGroup.
54-
// Regions configuration is needed if active-active domains are enabled.
55-
Regions map[string]RegionInformation `yaml:"regions"`
5651
// Deprecated: please use ClusterGroup
5752
ClusterInformation map[string]ClusterInformation `yaml:"clusterInformation"`
5853
}
@@ -85,12 +80,6 @@ type (
8580
Region string `yaml:"region"`
8681
}
8782

88-
RegionInformation struct {
89-
// InitialFailoverVersion is the identifier of each region.
90-
// It is used for active-active domains to determine the region of workflows which don't have an external entity mapping. (origin stickyness)
91-
InitialFailoverVersion int64 `yaml:"initialFailoverVersion"`
92-
}
93-
9483
AuthorizationProvider struct {
9584
// Enable indicates if the auth provider is enabled
9685
Enable bool `yaml:"enable"`

common/domain/handler.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,14 +1466,7 @@ func (d *handlerImpl) activeClustersFromRegisterRequest(registerRequest *types.R
14661466
// Initialize ActiveClustersByRegion with given cluster names and their initial failover versions
14671467
activeClustersByRegion := make(map[string]types.ActiveClusterInfo, len(registerRequest.ActiveClustersByRegion))
14681468
clusters := d.clusterMetadata.GetAllClusterInfo()
1469-
regions := d.clusterMetadata.GetAllRegionInfo()
14701469
for region, cluster := range registerRequest.ActiveClustersByRegion {
1471-
if _, ok := regions[region]; !ok {
1472-
return nil, &types.BadRequestError{
1473-
Message: fmt.Sprintf("Region %v not found. Domain cannot be registered in this region.", region),
1474-
}
1475-
}
1476-
14771470
clusterInfo, ok := clusters[cluster]
14781471
if !ok {
14791472
return nil, &types.BadRequestError{

common/domain/handler_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,28 +322,6 @@ func TestRegisterDomain(t *testing.T) {
322322
wantErr: true,
323323
expectedErr: &types.BadRequestError{Message: "Invalid local domain active cluster"},
324324
},
325-
{
326-
name: "active-active domain with an invalid region in request",
327-
request: &types.RegisterDomainRequest{
328-
Name: "active-active-domain",
329-
IsGlobalDomain: true,
330-
ActiveClustersByRegion: map[string]string{
331-
cluster.TestRegion1: cluster.TestCurrentClusterName,
332-
"invalid-region": cluster.TestAlternativeClusterName,
333-
},
334-
Clusters: []*types.ClusterReplicationConfiguration{
335-
{ClusterName: cluster.TestCurrentClusterName},
336-
{ClusterName: cluster.TestAlternativeClusterName},
337-
},
338-
WorkflowExecutionRetentionPeriodInDays: 3,
339-
},
340-
isPrimaryCluster: true,
341-
mockSetup: func(mockDomainMgr *persistence.MockDomainManager, mockReplicator *MockReplicator, request *types.RegisterDomainRequest) {
342-
mockDomainMgr.EXPECT().GetDomain(gomock.Any(), &persistence.GetDomainRequest{Name: request.Name}).Return(nil, &types.EntityNotExistsError{})
343-
},
344-
wantErr: true,
345-
expectedErr: &types.BadRequestError{},
346-
},
347325
{
348326
name: "active-active domain with an invalid cluster in request",
349327
request: &types.RegisterDomainRequest{

docker/config_template.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,6 @@ clusterGroupMetadata:
264264
region: "region1"
265265
{{- end }}
266266
{{- end }}
267-
{{- if .Env.ENABLE_GLOBAL_ACTIVE_ACTIVE_DOMAIN }}
268-
regions:
269-
region0:
270-
initialFailoverVersion: 1
271-
region1:
272-
initialFailoverVersion: 3
273-
{{- end }}
274267

275268
archival:
276269
history:

0 commit comments

Comments
 (0)