Skip to content

Commit

Permalink
Removed global domain enabled config (cadence-workflow#4845)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius authored May 26, 2022
1 parent 3a813e8 commit c6ce732
Show file tree
Hide file tree
Showing 61 changed files with 121 additions and 807 deletions.
2 changes: 0 additions & 2 deletions cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ func (s *server) startService() common.Daemon {
params.MetricsClient = metrics.NewClient(params.MetricScope, service.GetMetricsServiceIdx(params.Name, params.Logger))

params.ClusterMetadata = cluster.NewMetadata(
params.Logger,
dc.GetBoolProperty(dynamicconfig.EnableGlobalDomain, clusterGroupMetadata.EnableGlobalDomain),
clusterGroupMetadata.FailoverVersionIncrement,
clusterGroupMetadata.PrimaryClusterName,
clusterGroupMetadata.CurrentClusterName,
Expand Down
6 changes: 2 additions & 4 deletions common/cache/domainCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,8 @@ func (c *domainCache) updateIDToDomainCache(
entry.Lock()
defer entry.Unlock()

triggerCallback := c.clusterMetadata.IsGlobalDomainEnabled() &&
// initialized will be true when the entry contains valid data
entry.initialized &&
record.notificationVersion > entry.notificationVersion
// initialized will be true when the entry contains valid data
triggerCallback := entry.initialized && record.notificationVersion > entry.notificationVersion

entry.info = record.info
entry.config = record.config
Expand Down
12 changes: 0 additions & 12 deletions common/cache/domainCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/clock"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/dynamicconfig"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/log/loggerimpl"
"github.com/uber/cadence/common/metrics"
Expand Down Expand Up @@ -154,7 +153,6 @@ func (s *domainCacheSuite) TestListDomain() {
pageToken := []byte("some random page token")

s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
s.metadataMgr.On("ListDomains", mock.Anything, &persistence.ListDomainsRequest{
PageSize: domainCacheRefreshPageSize,
NextPageToken: nil,
Expand Down Expand Up @@ -197,7 +195,6 @@ func (s *domainCacheSuite) TestListDomain() {
}

func (s *domainCacheSuite) TestGetDomain_NonLoaded_GetByName() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
domainRecord := &persistence.GetDomainResponse{
Expand Down Expand Up @@ -241,7 +238,6 @@ func (s *domainCacheSuite) TestGetDomain_NonLoaded_GetByName() {
}

func (s *domainCacheSuite) TestGetDomain_NonLoaded_GetByID() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
domainRecord := &persistence.GetDomainResponse{
Expand Down Expand Up @@ -280,7 +276,6 @@ func (s *domainCacheSuite) TestGetDomain_NonLoaded_GetByID() {
}

func (s *domainCacheSuite) TestGetActiveDomainEntry_LocalDomain() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)

Expand Down Expand Up @@ -317,7 +312,6 @@ func (s *domainCacheSuite) TestGetActiveDomainEntry_LocalDomain() {
}

func (s *domainCacheSuite) TestGetActiveDomainEntry_ActiveGlobalDomain() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
s.clusterMetadata.On("GetCurrentClusterName").Return(cluster.TestCurrentClusterName)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
Expand Down Expand Up @@ -356,7 +350,6 @@ func (s *domainCacheSuite) TestGetActiveDomainEntry_ActiveGlobalDomain() {
}

func (s *domainCacheSuite) TestGetActiveDomainEntry_PassiveGlobalDomain() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
s.clusterMetadata.On("GetCurrentClusterName").Return(cluster.TestCurrentClusterName)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
Expand Down Expand Up @@ -441,7 +434,6 @@ func (s *domainCacheSuite) TestRegisterCallback_CatchUp() {
domainNotificationVersion++

s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil).Once()
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
s.metadataMgr.On("ListDomains", mock.Anything, &persistence.ListDomainsRequest{
PageSize: domainCacheRefreshPageSize,
NextPageToken: nil,
Expand Down Expand Up @@ -519,7 +511,6 @@ func (s *domainCacheSuite) TestUpdateCache_TriggerCallBack() {
domainNotificationVersion++

s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil).Once()
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
s.metadataMgr.On("ListDomains", mock.Anything, &persistence.ListDomainsRequest{
PageSize: domainCacheRefreshPageSize,
NextPageToken: nil,
Expand Down Expand Up @@ -605,7 +596,6 @@ func (s *domainCacheSuite) TestUpdateCache_TriggerCallBack() {
}

func (s *domainCacheSuite) TestGetTriggerListAndUpdateCache_ConcurrentAccess() {
s.clusterMetadata.On("IsGlobalDomainEnabled").Return(true)
domainNotificationVersion := int64(999999) // make this notification version really large for test
s.metadataMgr.On("GetMetadata", mock.Anything).Return(&persistence.GetMetadataResponse{NotificationVersion: domainNotificationVersion}, nil)
id := uuid.New()
Expand Down Expand Up @@ -764,8 +754,6 @@ func Test_IsSampledForLongerRetention(t *testing.T) {

func Test_DomainCacheEntry_GetDomainNotActiveErr(t *testing.T) {
clusterMetadata := cluster.NewMetadata(
loggerimpl.NewNopLogger(),
dynamicconfig.GetBoolPropertyFn(true),
int64(10),
cluster.TestCurrentClusterName,
cluster.TestCurrentClusterName,
Expand Down
19 changes: 0 additions & 19 deletions common/cluster/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ import (

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/config"
"github.com/uber/cadence/common/dynamicconfig"
"github.com/uber/cadence/common/log"
)

type (
// Metadata provides information about clusters
Metadata interface {
// IsGlobalDomainEnabled whether the global domain is enabled,
// this attr should be discarded when cross DC is made public
IsGlobalDomainEnabled() bool
// IsPrimaryCluster whether current cluster is the primary cluster
IsPrimaryCluster() bool
// GetNextFailoverVersion return the next failover version for domain failover
Expand All @@ -54,10 +49,6 @@ type (
}

metadataImpl struct {
logger log.Logger
// EnableGlobalDomain whether the global domain is enabled,
// this attr should be discarded when cross DC is made public
enableGlobalDomain dynamicconfig.BoolPropertyFn
// failoverVersionIncrement is the increment of each cluster's version when failover happen
failoverVersionIncrement int64
// primaryClusterName is the name of the primary cluster, only the primary cluster can register / update domain
Expand All @@ -74,8 +65,6 @@ type (

// NewMetadata create a new instance of Metadata
func NewMetadata(
logger log.Logger,
enableGlobalDomain dynamicconfig.BoolPropertyFn,
failoverVersionIncrement int64,
primaryClusterName string,
currentClusterName string,
Expand All @@ -87,8 +76,6 @@ func NewMetadata(
}

return &metadataImpl{
logger: logger,
enableGlobalDomain: enableGlobalDomain,
failoverVersionIncrement: failoverVersionIncrement,
primaryClusterName: primaryClusterName,
currentClusterName: currentClusterName,
Expand All @@ -97,12 +84,6 @@ func NewMetadata(
}
}

// IsGlobalDomainEnabled whether the global domain is enabled,
// this attr should be discarded when cross DC is made public
func (metadata *metadataImpl) IsGlobalDomainEnabled() bool {
return metadata.enableGlobalDomain()
}

// GetNextFailoverVersion return the next failover version based on input
func (metadata *metadataImpl) GetNextFailoverVersion(cluster string, currentFailoverVersion int64) int64 {
info, ok := metadata.clusterGroup[cluster]
Expand Down
21 changes: 3 additions & 18 deletions common/cluster/metadataTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ package cluster

import (
"github.com/uber/cadence/common/config"
"github.com/uber/cadence/common/dynamicconfig"
"github.com/uber/cadence/common/log/loggerimpl"
"github.com/uber/cadence/common/service"
)

Expand Down Expand Up @@ -90,29 +88,16 @@ var (
)

// GetTestClusterMetadata return an cluster metadata instance, which is initialized
func GetTestClusterMetadata(enableGlobalDomain bool, isPrimaryCluster bool) Metadata {
func GetTestClusterMetadata(isPrimaryCluster bool) Metadata {
primaryClusterName := TestCurrentClusterName
if !isPrimaryCluster {
primaryClusterName = TestAlternativeClusterName
}

if enableGlobalDomain {
return NewMetadata(
loggerimpl.NewNopLogger(),
dynamicconfig.GetBoolPropertyFn(true),
TestFailoverVersionIncrement,
primaryClusterName,
TestCurrentClusterName,
TestAllClusterInfo,
)
}

return NewMetadata(
loggerimpl.NewNopLogger(),
dynamicconfig.GetBoolPropertyFn(false),
TestFailoverVersionIncrement,
primaryClusterName,
TestCurrentClusterName,
TestCurrentClusterName,
TestSingleDCClusterInfo,
TestAllClusterInfo,
)
}
14 changes: 0 additions & 14 deletions common/cluster/metadata_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions common/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
type (
// ClusterGroupMetadata contains all the clusters participating in a replication group(aka XDC/GlobalDomain)
ClusterGroupMetadata struct {
EnableGlobalDomain bool `yaml:"enableGlobalDomain"`
// FailoverVersionIncrement is the increment of each cluster version when failover happens
// It decides the maximum number clusters in this replication groups
FailoverVersionIncrement int64 `yaml:"failoverVersionIncrement"`
Expand Down Expand Up @@ -90,11 +89,6 @@ func (m *ClusterGroupMetadata) Validate() error {
return errors.New("ClusterGroupMetadata cannot be empty")
}

if !m.EnableGlobalDomain {
log.Println("[WARN] Local domain is now deprecated. Please update config to enable global domain(ClusterGroupMetadata->EnableGlobalDomain)." +
"Global domain of single cluster has zero overhead, but only advantages for future migration and fail over. Please check Cadence documentation for more details.")
}

var errs error

if len(m.PrimaryClusterName) == 0 {
Expand Down
1 change: 0 additions & 1 deletion common/config/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func TestClusterGroupMetadataValidate(t *testing.T) {

func validClusterGroupMetadata() *ClusterGroupMetadata {
return &ClusterGroupMetadata{
EnableGlobalDomain: true,
FailoverVersionIncrement: 10,
PrimaryClusterName: "active",
CurrentClusterName: "standby",
Expand Down
13 changes: 3 additions & 10 deletions common/domain/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,9 @@ func (d *handlerImpl) RegisterDomain(
registerRequest *types.RegisterDomainRequest,
) error {

if !d.clusterMetadata.IsGlobalDomainEnabled() {
if registerRequest.IsGlobalDomain {
return &types.BadRequestError{Message: "Cannot register global domain when not enabled. Please update config to enable global domain(recommended), " +
"or specify explicit parameter to create legacy local domain. Global domain of single cluster has zero overhead, but only advantages for future migration and fail over. Please check Cadence documentation for more details."}
}
} else {
// cluster global domain enabled
if !d.clusterMetadata.IsPrimaryCluster() && registerRequest.GetIsGlobalDomain() {
return errNotPrimaryCluster
}
// cluster global domain enabled
if !d.clusterMetadata.IsPrimaryCluster() && registerRequest.GetIsGlobalDomain() {
return errNotPrimaryCluster
}

// first check if the name is already registered as the local domain
Expand Down
Loading

0 comments on commit c6ce732

Please sign in to comment.