Skip to content

Commit d09cb44

Browse files
authored
chore(active-active): remove deprecated fields (#7388)
<!-- Describe what has changed in this PR --> **What changed?** - remove deprecated fields <!-- Tell your future self why have you made these changes --> **Why?** code cleanup <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> **How did you test it?** unit 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** <!-- 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 6106bea commit d09cb44

File tree

13 files changed

+50
-201
lines changed

13 files changed

+50
-201
lines changed

common/persistence/execution_manager_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,10 @@ func sampleActiveClusterSelectionPolicyData() *DataBlob {
16521652

16531653
func sampleActiveClusterSelectionPolicy() *types.ActiveClusterSelectionPolicy {
16541654
return &types.ActiveClusterSelectionPolicy{
1655-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyRegionSticky.Ptr(),
1656-
StickyRegion: "region-1",
1655+
ClusterAttribute: &types.ClusterAttribute{
1656+
Scope: "region",
1657+
Name: "us-west-1",
1658+
},
16571659
}
16581660
}
16591661

common/persistence/persistence-tests/executionManagerTest.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,10 @@ func (s *ExecutionManagerSuite) TestGetWorkflow() {
14981498
Memo: testMemo,
14991499
PartitionConfig: testPartitionConfig,
15001500
ActiveClusterSelectionPolicy: &types.ActiveClusterSelectionPolicy{
1501-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyRegionSticky.Ptr(),
1502-
StickyRegion: "region1",
1501+
ClusterAttribute: &types.ClusterAttribute{
1502+
Scope: "region",
1503+
Name: "us-west-1",
1504+
},
15031505
},
15041506
},
15051507
ExecutionStats: &p.ExecutionStats{

common/persistence/serializer_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ func generateActiveClusters() *types.ActiveClusters {
539539

540540
func generateActiveClusterSelectionPolicy() *types.ActiveClusterSelectionPolicy {
541541
return &types.ActiveClusterSelectionPolicy{
542-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyRegionSticky.Ptr(),
543-
StickyRegion: "region1",
544-
ExternalEntityType: "externalEntityType1",
545-
ExternalEntityKey: "externalEntityKey1",
542+
ClusterAttribute: &types.ClusterAttribute{
543+
Scope: "region",
544+
Name: "us-west-1",
545+
},
546546
}
547547
}

common/types/mapper/proto/api.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6569,30 +6569,6 @@ func FromActiveClusterSelectionPolicy(p *types.ActiveClusterSelectionPolicy) *ap
65696569
if p == nil {
65706570
return nil
65716571
}
6572-
// TODO(active-active): Remove the switch statement once the strategy is removed
6573-
switch p.GetStrategy() {
6574-
case types.ActiveClusterSelectionStrategyRegionSticky:
6575-
return &apiv1.ActiveClusterSelectionPolicy{
6576-
Strategy: apiv1.ActiveClusterSelectionStrategy_ACTIVE_CLUSTER_SELECTION_STRATEGY_REGION_STICKY,
6577-
StrategyConfig: &apiv1.ActiveClusterSelectionPolicy_ActiveClusterStickyRegionConfig{
6578-
ActiveClusterStickyRegionConfig: &apiv1.ActiveClusterStickyRegionConfig{
6579-
StickyRegion: p.StickyRegion,
6580-
},
6581-
},
6582-
ClusterAttribute: FromClusterAttribute(p.ClusterAttribute),
6583-
}
6584-
case types.ActiveClusterSelectionStrategyExternalEntity:
6585-
return &apiv1.ActiveClusterSelectionPolicy{
6586-
Strategy: apiv1.ActiveClusterSelectionStrategy_ACTIVE_CLUSTER_SELECTION_STRATEGY_EXTERNAL_ENTITY,
6587-
StrategyConfig: &apiv1.ActiveClusterSelectionPolicy_ActiveClusterExternalEntityConfig{
6588-
ActiveClusterExternalEntityConfig: &apiv1.ActiveClusterExternalEntityConfig{
6589-
ExternalEntityType: p.ExternalEntityType,
6590-
ExternalEntityKey: p.ExternalEntityKey,
6591-
},
6592-
},
6593-
ClusterAttribute: FromClusterAttribute(p.ClusterAttribute),
6594-
}
6595-
}
65966572
return &apiv1.ActiveClusterSelectionPolicy{
65976573
ClusterAttribute: FromClusterAttribute(p.ClusterAttribute),
65986574
}
@@ -6602,22 +6578,6 @@ func ToActiveClusterSelectionPolicy(p *apiv1.ActiveClusterSelectionPolicy) *type
66026578
if p == nil {
66036579
return nil
66046580
}
6605-
// TODO(active-active): Remove the switch statement once the strategy is removed
6606-
switch p.Strategy {
6607-
case apiv1.ActiveClusterSelectionStrategy_ACTIVE_CLUSTER_SELECTION_STRATEGY_REGION_STICKY:
6608-
return &types.ActiveClusterSelectionPolicy{
6609-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyRegionSticky.Ptr(),
6610-
StickyRegion: p.StrategyConfig.(*apiv1.ActiveClusterSelectionPolicy_ActiveClusterStickyRegionConfig).ActiveClusterStickyRegionConfig.StickyRegion,
6611-
ClusterAttribute: ToClusterAttribute(p.ClusterAttribute),
6612-
}
6613-
case apiv1.ActiveClusterSelectionStrategy_ACTIVE_CLUSTER_SELECTION_STRATEGY_EXTERNAL_ENTITY:
6614-
return &types.ActiveClusterSelectionPolicy{
6615-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyExternalEntity.Ptr(),
6616-
ExternalEntityType: p.StrategyConfig.(*apiv1.ActiveClusterSelectionPolicy_ActiveClusterExternalEntityConfig).ActiveClusterExternalEntityConfig.ExternalEntityType,
6617-
ExternalEntityKey: p.StrategyConfig.(*apiv1.ActiveClusterSelectionPolicy_ActiveClusterExternalEntityConfig).ActiveClusterExternalEntityConfig.ExternalEntityKey,
6618-
ClusterAttribute: ToClusterAttribute(p.ClusterAttribute),
6619-
}
6620-
}
66216581
return &types.ActiveClusterSelectionPolicy{
66226582
ClusterAttribute: ToClusterAttribute(p.ClusterAttribute),
66236583
}

common/types/mapper/thrift/shared.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7045,11 +7045,7 @@ func FromActiveClusterSelectionPolicy(t *types.ActiveClusterSelectionPolicy) *sh
70457045
return nil
70467046
}
70477047
return &shared.ActiveClusterSelectionPolicy{
7048-
Strategy: FromActiveClusterSelectionStrategy(t.ActiveClusterSelectionStrategy),
7049-
ExternalEntityType: &t.ExternalEntityType,
7050-
ExternalEntityKey: &t.ExternalEntityKey,
7051-
StickyRegion: &t.StickyRegion,
7052-
ClusterAttribute: FromClusterAttribute(t.ClusterAttribute),
7048+
ClusterAttribute: FromClusterAttribute(t.ClusterAttribute),
70537049
}
70547050
}
70557051

@@ -7058,40 +7054,10 @@ func ToActiveClusterSelectionPolicy(t *shared.ActiveClusterSelectionPolicy) *typ
70587054
return nil
70597055
}
70607056
return &types.ActiveClusterSelectionPolicy{
7061-
ActiveClusterSelectionStrategy: ToActiveClusterSelectionStrategy(t.Strategy),
7062-
ExternalEntityType: *t.ExternalEntityType,
7063-
ExternalEntityKey: *t.ExternalEntityKey,
7064-
StickyRegion: *t.StickyRegion,
7065-
ClusterAttribute: ToClusterAttribute(t.ClusterAttribute),
7057+
ClusterAttribute: ToClusterAttribute(t.ClusterAttribute),
70667058
}
70677059
}
70687060

7069-
func FromActiveClusterSelectionStrategy(t *types.ActiveClusterSelectionStrategy) *shared.ActiveClusterSelectionStrategy {
7070-
if t == nil {
7071-
return nil
7072-
}
7073-
switch *t {
7074-
case types.ActiveClusterSelectionStrategyRegionSticky:
7075-
return shared.ActiveClusterSelectionStrategyRegionSticky.Ptr()
7076-
case types.ActiveClusterSelectionStrategyExternalEntity:
7077-
return shared.ActiveClusterSelectionStrategyExternalEntity.Ptr()
7078-
}
7079-
panic("unexpected enum value")
7080-
}
7081-
7082-
func ToActiveClusterSelectionStrategy(t *shared.ActiveClusterSelectionStrategy) *types.ActiveClusterSelectionStrategy {
7083-
if t == nil {
7084-
return nil
7085-
}
7086-
switch *t {
7087-
case shared.ActiveClusterSelectionStrategyRegionSticky:
7088-
return types.ActiveClusterSelectionStrategyRegionSticky.Ptr()
7089-
case shared.ActiveClusterSelectionStrategyExternalEntity:
7090-
return types.ActiveClusterSelectionStrategyExternalEntity.Ptr()
7091-
}
7092-
panic("unexpected enum value")
7093-
}
7094-
70957061
// FromWorkflowExecutionTerminatedEventAttributes converts internal WorkflowExecutionTerminatedEventAttributes type to thrift
70967062
func FromWorkflowExecutionTerminatedEventAttributes(t *types.WorkflowExecutionTerminatedEventAttributes) *shared.WorkflowExecutionTerminatedEventAttributes {
70977063
if t == nil {

common/types/mapper/thrift/shared_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,8 +3594,6 @@ func TestActiveClusterSelectionPolicyConversion(t *testing.T) {
35943594
testCases := []*types.ActiveClusterSelectionPolicy{
35953595
nil,
35963596
{},
3597-
&testdata.ActiveClusterSelectionPolicyExternalEntity,
3598-
&testdata.ActiveClusterSelectionPolicyRegionSticky,
35993597
&testdata.ActiveClusterSelectionPolicyWithClusterAttribute,
36003598
}
36013599

common/types/shared.go

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,22 +2709,7 @@ func (c *ClusterAttribute) Equals(other *ClusterAttribute) bool {
27092709
return c.Scope == other.Scope && c.Name == other.Name
27102710
}
27112711

2712-
type ActiveClusterSelectionStrategy int32
2713-
2714-
const (
2715-
ActiveClusterSelectionStrategyRegionSticky ActiveClusterSelectionStrategy = iota
2716-
ActiveClusterSelectionStrategyExternalEntity
2717-
)
2718-
27192712
type ActiveClusterSelectionPolicy struct {
2720-
ActiveClusterSelectionStrategy *ActiveClusterSelectionStrategy `json:"activeClusterSelectionStrategy,omitempty"`
2721-
2722-
StickyRegion string `json:"stickyRegion,omitempty"`
2723-
2724-
ExternalEntityType string `json:"externalEntityType,omitempty"`
2725-
ExternalEntityKey string `json:"externalEntityKey,omitempty"`
2726-
2727-
// TODO(active-active): Remove the fields above
27282713
ClusterAttribute *ClusterAttribute `json:"clusterAttribute,omitempty" yaml:"clusterAttribute,omitempty"`
27292714
}
27302715

@@ -2743,54 +2728,7 @@ func (p *ActiveClusterSelectionPolicy) Equals(other *ActiveClusterSelectionPolic
27432728
return false
27442729
}
27452730

2746-
return p.GetStrategy() == other.GetStrategy() &&
2747-
p.StickyRegion == other.StickyRegion &&
2748-
p.ExternalEntityType == other.ExternalEntityType &&
2749-
p.ExternalEntityKey == other.ExternalEntityKey && p.ClusterAttribute.Equals(other.ClusterAttribute)
2750-
}
2751-
2752-
func (p *ActiveClusterSelectionPolicy) GetStrategy() ActiveClusterSelectionStrategy {
2753-
if p == nil || p.ActiveClusterSelectionStrategy == nil {
2754-
return ActiveClusterSelectionStrategyRegionSticky
2755-
}
2756-
return *p.ActiveClusterSelectionStrategy
2757-
}
2758-
2759-
func (e ActiveClusterSelectionStrategy) Ptr() *ActiveClusterSelectionStrategy {
2760-
return &e
2761-
}
2762-
2763-
func (e ActiveClusterSelectionStrategy) String() string {
2764-
switch e {
2765-
case ActiveClusterSelectionStrategyRegionSticky:
2766-
return "REGION_STICKY"
2767-
case ActiveClusterSelectionStrategyExternalEntity:
2768-
return "EXTERNAL_ENTITY"
2769-
}
2770-
2771-
return fmt.Sprintf("ActiveClusterSelectionStrategy(%d)", e)
2772-
}
2773-
2774-
func (e ActiveClusterSelectionStrategy) MarshalText() ([]byte, error) {
2775-
return []byte(e.String()), nil
2776-
}
2777-
2778-
func (e *ActiveClusterSelectionStrategy) UnmarshalText(value []byte) error {
2779-
switch s := strings.ToUpper(string(value)); s {
2780-
case "REGION_STICKY":
2781-
*e = ActiveClusterSelectionStrategyRegionSticky
2782-
return nil
2783-
case "EXTERNAL_ENTITY":
2784-
*e = ActiveClusterSelectionStrategyExternalEntity
2785-
return nil
2786-
default:
2787-
val, err := strconv.ParseInt(s, 10, 32)
2788-
if err != nil {
2789-
return fmt.Errorf("unknown enum value %q for %q: %v", s, "ActiveClusterSelectionStrategy", err)
2790-
}
2791-
*e = ActiveClusterSelectionStrategy(val)
2792-
return nil
2793-
}
2731+
return p.ClusterAttribute.Equals(other.ClusterAttribute)
27942732
}
27952733

27962734
// DomainStatus is an internal type (TBD...)

common/types/testdata/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,6 @@ var (
500500
},
501501
ExclusiveMaxReadLevel: &TaskKey,
502502
}
503-
ActiveClusterSelectionPolicyRegionSticky = types.ActiveClusterSelectionPolicy{
504-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyRegionSticky.Ptr(),
505-
StickyRegion: "region1",
506-
}
507-
ActiveClusterSelectionPolicyExternalEntity = types.ActiveClusterSelectionPolicy{
508-
ActiveClusterSelectionStrategy: types.ActiveClusterSelectionStrategyExternalEntity.Ptr(),
509-
ExternalEntityType: "externalEntityType1",
510-
ExternalEntityKey: "externalEntityKey1",
511-
}
512503
ClusterAttribute = types.ClusterAttribute{
513504
Scope: "region",
514505
Name: "us-west-1",

common/types/testdata/history.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ var (
276276
Header: &Header,
277277
PartitionConfig: PartitionConfig,
278278
RequestID: RequestID,
279-
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyExternalEntity,
279+
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyWithClusterAttribute,
280280
CronOverlapPolicy: &CronOverlapPolicy,
281281
}
282282
WorkflowExecutionCompletedEventAttributes = types.WorkflowExecutionCompletedEventAttributes{
@@ -476,7 +476,7 @@ var (
476476
Header: &Header,
477477
Memo: &Memo,
478478
SearchAttributes: &SearchAttributes,
479-
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyExternalEntity,
479+
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyWithClusterAttribute,
480480
CronOverlapPolicy: &CronOverlapPolicy,
481481
}
482482
StartChildWorkflowExecutionInitiatedEventAttributes = types.StartChildWorkflowExecutionInitiatedEventAttributes{

common/types/testdata/service_frontend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ var (
346346
SearchAttributes: &SearchAttributes,
347347
Header: &Header,
348348
FirstRunAtTimeStamp: &Timestamp1,
349-
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyExternalEntity,
349+
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyWithClusterAttribute,
350350
}
351351
StartWorkflowExecutionResponse = types.StartWorkflowExecutionResponse{
352352
RunID: RunID,
@@ -385,7 +385,7 @@ var (
385385
SearchAttributes: &SearchAttributes,
386386
Header: &Header,
387387
FirstRunAtTimestamp: &Timestamp1,
388-
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyRegionSticky,
388+
ActiveClusterSelectionPolicy: &ActiveClusterSelectionPolicyWithClusterAttribute,
389389
}
390390
SignalWithStartWorkflowExecutionAsyncRequest = types.SignalWithStartWorkflowExecutionAsyncRequest{
391391
SignalWithStartWorkflowExecutionRequest: &SignalWithStartWorkflowExecutionRequest,

0 commit comments

Comments
 (0)