Skip to content

Commit 70c5df0

Browse files
authored
Remove unused method from active cluster manager interface (#7272)
<!-- Describe what has changed in this PR --> **What changed?** Remove unused method from active cluster manager interface. There was a design decision change to get rid of the region concept from Cadence. And there is no need to have failover versions for regions. <!-- Tell your future self why have you made these changes --> **Why?** - LookupCluster method is not used in the codebase - ClusterNameForFailoverVersion is not needed anymore <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> **How did you test it?** Unit tests, 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** <!-- 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** Signed-off-by: Zijian <[email protected]>
1 parent 2050121 commit 70c5df0

25 files changed

+45
-789
lines changed

common/activecluster/manager.go

Lines changed: 2 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,7 @@ func (m *managerImpl) LookupNewWorkflow(ctx context.Context, domainID string, po
245245
}, nil
246246
}
247247

248-
if policy.GetStrategy() != types.ActiveClusterSelectionStrategyExternalEntity {
249-
return nil, fmt.Errorf("unsupported active cluster selection strategy: %s", policy.GetStrategy())
250-
}
251-
252-
// find cluster name & failover version of the external entity
253-
externalEntity, err := m.getExternalEntity(ctx, policy.ExternalEntityType, policy.ExternalEntityKey)
254-
if err != nil {
255-
return nil, err
256-
}
257-
cluster, err := m.ClusterNameForFailoverVersion(externalEntity.FailoverVersion, domainID)
258-
if err != nil {
259-
return nil, err
260-
}
261-
262-
return &LookupResult{
263-
Region: externalEntity.Region,
264-
ClusterName: cluster,
265-
FailoverVersion: externalEntity.FailoverVersion,
266-
}, nil
248+
return nil, fmt.Errorf("unsupported active cluster selection strategy: %s", policy.GetStrategy())
267249
}
268250

269251
func (m *managerImpl) LookupWorkflow(ctx context.Context, domainID, wfID, rID string) (res *LookupResult, e error) {
@@ -345,7 +327,7 @@ func (m *managerImpl) LookupWorkflow(ctx context.Context, domainID, wfID, rID st
345327
return nil, err
346328
}
347329

348-
cluster, err := m.ClusterNameForFailoverVersion(externalEntity.FailoverVersion, domainID)
330+
cluster, err := m.clusterMetadata.ClusterNameForFailoverVersion(externalEntity.FailoverVersion)
349331
if err != nil {
350332
return nil, err
351333
}
@@ -398,88 +380,6 @@ func (m *managerImpl) LookupWorkflow(ctx context.Context, domainID, wfID, rID st
398380
}, nil
399381
}
400382

401-
func (m *managerImpl) LookupCluster(ctx context.Context, domainID, clusterName string) (res *LookupResult, e error) {
402-
d, scope, err := m.getDomainAndScope(domainID, LookupClusterOpName)
403-
if err != nil {
404-
return nil, err
405-
}
406-
defer m.handleError(scope, &e, time.Now())
407-
408-
clusterInfo, ok := m.clusterMetadata.GetAllClusterInfo()[clusterName]
409-
if !ok {
410-
return nil, newClusterNotFoundError(clusterName)
411-
}
412-
413-
if !d.GetReplicationConfig().IsActiveActive() {
414-
// Not an active-active domain. return ActiveClusterName from domain entry
415-
m.logger.Debug("LookupCluster: not an active-active domain. returning given clusterName",
416-
tag.WorkflowDomainID(domainID),
417-
tag.ClusterName(clusterName),
418-
)
419-
420-
return &LookupResult{
421-
ClusterName: clusterName,
422-
FailoverVersion: clusterInfo.InitialFailoverVersion,
423-
Region: clusterInfo.Region,
424-
}, nil
425-
}
426-
427-
region := clusterInfo.Region
428-
activeCluster, ok := d.GetReplicationConfig().ActiveClusters.ActiveClustersByRegion[region]
429-
if !ok {
430-
return nil, newRegionNotFoundForDomainError(region, domainID)
431-
}
432-
433-
return &LookupResult{
434-
Region: region,
435-
ClusterName: activeCluster.ActiveClusterName,
436-
FailoverVersion: activeCluster.FailoverVersion,
437-
}, nil
438-
}
439-
440-
func (m *managerImpl) ClusterNameForFailoverVersion(failoverVersion int64, domainID string) (string, error) {
441-
d, err := m.domainIDToDomainFn(domainID)
442-
if err != nil {
443-
return "", err
444-
}
445-
446-
if !d.GetReplicationConfig().IsActiveActive() {
447-
cluster, err := m.clusterMetadata.ClusterNameForFailoverVersion(failoverVersion)
448-
if err != nil {
449-
return "", err
450-
}
451-
return cluster, nil
452-
}
453-
454-
// For active-active domains, the failover version might be mapped to a cluster or a region
455-
// First check if it maps to a cluster
456-
cluster, err := m.clusterMetadata.ClusterNameForFailoverVersion(failoverVersion)
457-
if err == nil {
458-
// failover version belongs to a cluster.
459-
return cluster, nil
460-
}
461-
462-
// Check if it maps to a region.
463-
region, err := m.clusterMetadata.RegionForFailoverVersion(failoverVersion)
464-
if err != nil {
465-
return "", err
466-
}
467-
468-
// Now we know the region, find the cluster in the domain's active cluster list which belongs to the region
469-
cfg, ok := d.GetReplicationConfig().ActiveClusters.ActiveClustersByRegion[region]
470-
if !ok {
471-
return "", newRegionNotFoundForDomainError(region, domainID)
472-
}
473-
474-
allClusters := m.clusterMetadata.GetAllClusterInfo()
475-
_, ok = allClusters[cfg.ActiveClusterName]
476-
if !ok {
477-
return "", newClusterNotFoundForRegionError(cfg.ActiveClusterName, region)
478-
}
479-
480-
return cfg.ActiveClusterName, nil
481-
}
482-
483383
func (m *managerImpl) RegisterChangeCallback(shardID int, callback func(ChangeType)) {
484384
m.changeCallbacksLock.Lock()
485385
defer m.changeCallbacksLock.Unlock()

common/activecluster/manager_mock.go

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)