Skip to content

Commit 3ade263

Browse files
authored
Allow setting cluster Id explicitly (#3883)
* Allow setting cluster Id explicitly * ignore cluster id from yaml config * don't fail on incorrect cluster id * Update temporal/fx.go * Update temporal/fx.go * Update temporal/fx.go
1 parent 20a5ce3 commit 3ade263

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

common/cluster/metadata.go

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ type (
104104
InitialFailoverVersion int64 `yaml:"initialFailoverVersion"`
105105
// Address indicate the remote service address(Host:Port). Host can be DNS name.
106106
RPCAddress string `yaml:"rpcAddress"`
107+
// Cluster ID allows to explicitly set the ID of the cluster. Optional.
108+
ClusterID string `yaml:"-"`
107109
ShardCount int32 `yaml:"-"` // Ignore this field when loading config.
108110
// private field to track cluster information updates
109111
version int64

temporal/fx.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,21 @@ func ApplyClusterMetadataConfigProvider(
662662
tag.Key("clusterInformation"),
663663
tag.ClusterName(clusterName),
664664
tag.IgnoredValue(clusterInfo))
665+
666+
// Only configure current cluster metadata from static config file
665667
continue
666668
}
667669

668-
// Only configure current cluster metadata from static config file
669-
clusterId := uuid.New()
670+
var clusterId string
671+
if uuid.Parse(clusterInfo.ClusterID) == nil {
672+
if clusterInfo.ClusterID != "" {
673+
logger.Warn("Cluster Id in Cluster Metadata config is not a valid uuid. Generating a new Cluster Id")
674+
}
675+
clusterId = uuid.New()
676+
} else {
677+
clusterId = clusterInfo.ClusterID
678+
}
679+
670680
applied, err := clusterMetadataManager.SaveClusterMetadata(
671681
ctx,
672682
&persistence.SaveClusterMetadataRequest{

0 commit comments

Comments
 (0)