Skip to content

Commit

Permalink
Add missing IsolationGroups field in domain cache entry (uber#5679)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir authored Feb 21, 2024
1 parent f599839 commit d7479ca
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/cache/domainCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func (entry *DomainCacheEntry) duplicate() *DomainCacheEntry {
VisibilityArchivalURI: entry.config.VisibilityArchivalURI,
BadBinaries: copyResetBinary(entry.config.BadBinaries),
AsyncWorkflowConfig: entry.config.AsyncWorkflowConfig.DeepCopy(),
// Q: Should we set IsolationGroups as well? Othewise domaincache will not be able to detect changes in isolation groups
IsolationGroups: entry.config.IsolationGroups.DeepCopy(),
}
result.replicationConfig = &persistence.DomainReplicationConfig{
ActiveClusterName: entry.replicationConfig.ActiveClusterName,
Expand Down
10 changes: 10 additions & 0 deletions common/cache/domainCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ func (s *domainCacheSuite) TestListDomain() {
Enabled: true,
PredefinedQueueName: "test-async-wf-queue",
},
IsolationGroups: types.IsolationGroupConfiguration{
"zone-1": {
Name: "zone-1",
State: types.IsolationGroupStateDrained,
},
"zone-2": {
Name: "zone-2",
State: types.IsolationGroupStateHealthy,
},
},
},
ReplicationConfig: &persistence.DomainReplicationConfig{
ActiveClusterName: cluster.TestCurrentClusterName,
Expand Down
12 changes: 12 additions & 0 deletions common/types/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,18 @@ func (i IsolationGroupConfiguration) ToPartitionList() []IsolationGroupPartition
return out
}

func (i IsolationGroupConfiguration) DeepCopy() IsolationGroupConfiguration {
if i == nil {
return nil
}

out := IsolationGroupConfiguration{}
for k, v := range i {
out[k] = v
}
return out
}

// FromIsolationGroupPartitionList maps a list of isolation to the internal IsolationGroup configuration type
// whose map keys tend to be used more for set operations
func FromIsolationGroupPartitionList(in []IsolationGroupPartition) IsolationGroupConfiguration {
Expand Down
56 changes: 56 additions & 0 deletions common/types/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,62 @@ func TestIsolationGroupConfiguration_ToPartitionList(t *testing.T) {
}
}

func TestIsolationGroupConfigurationDeepCopy(t *testing.T) {
tests := []struct {
name string
input IsolationGroupConfiguration
}{
{
name: "nil",
input: nil,
},
{
name: "empty",
input: IsolationGroupConfiguration{},
},
{
name: "single group",
input: IsolationGroupConfiguration{
"zone-1": {
Name: "zone-1",
State: IsolationGroupStateDrained,
},
},
},
{
name: "multiple groups",
input: IsolationGroupConfiguration{
"zone-1": {
Name: "zone-1",
State: IsolationGroupStateDrained,
},
"zone-2": {
Name: "zone-2",
State: IsolationGroupStateHealthy,
},
"zone-3": {
Name: "zone-3",
State: IsolationGroupStateDrained,
},
},
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
got := tc.input.DeepCopy()
assert.Equal(t, tc.input, got)

if tc.input == nil {
return
}

tc.input["new"] = IsolationGroupPartition{Name: "new", State: IsolationGroupStateHealthy}
assert.NotEqual(t, tc.input, got)
})
}
}

func TestAsyncWorkflowConfigurationDeepCopy(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit d7479ca

Please sign in to comment.