Skip to content

Commit

Permalink
Favor local config value on enable global namespace (#2368)
Browse files Browse the repository at this point in the history
* Favor config value in enable global namespace

* Add comment

* Update cluster metadata info if enable namespace changed
  • Loading branch information
yux0 committed Jan 12, 2022
1 parent b535b87 commit 6ffdaaa
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions temporal/fx.go
Expand Up @@ -604,14 +604,6 @@ func ApplyClusterMetadataConfigProvider(
tag.Value(persistedShardCount))
config.Persistence.NumHistoryShards = persistedShardCount
}
if resp.IsGlobalNamespaceEnabled != clusterData.EnableGlobalNamespace {
logger.Error(
mismatchLogMessage,
tag.Key("clusterMetadata.EnableGlobalNamespace"),
tag.IgnoredValue(clusterData.EnableGlobalNamespace),
tag.Value(resp.IsGlobalNamespaceEnabled))
config.ClusterMetadata.EnableGlobalNamespace = resp.IsGlobalNamespaceEnabled
}
if resp.FailoverVersionIncrement != clusterData.FailoverVersionIncrement {
logger.Error(
mismatchLogMessage,
Expand All @@ -620,6 +612,25 @@ func ApplyClusterMetadataConfigProvider(
tag.Value(resp.FailoverVersionIncrement))
config.ClusterMetadata.FailoverVersionIncrement = resp.FailoverVersionIncrement
}
if resp.IsGlobalNamespaceEnabled != clusterData.EnableGlobalNamespace {
applied, err = clusterMetadataManager.SaveClusterMetadata(
&persistence.SaveClusterMetadataRequest{
ClusterMetadata: persistencespb.ClusterMetadata{
HistoryShardCount: resp.HistoryShardCount,
ClusterName: resp.ClusterName,
ClusterId: resp.ClusterId,
ClusterAddress: resp.ClusterAddress,
FailoverVersionIncrement: resp.FailoverVersionIncrement,
InitialFailoverVersion: resp.InitialFailoverVersion,
IsGlobalNamespaceEnabled: clusterData.EnableGlobalNamespace,
IsConnectionEnabled: resp.IsConnectionEnabled,
},
Version: resp.Version,
})
if !applied || err != nil {
return config.ClusterMetadata, config.Persistence, fmt.Errorf("error while updating cluster metadata: %w", err)
}
}
}
case *serviceerror.NotFound:
if clusterName == clusterData.CurrentClusterName {
Expand Down

0 comments on commit 6ffdaaa

Please sign in to comment.