From 3ade2631d9ee42eb53a20104919e1bf78721642f Mon Sep 17 00:00:00 2001 From: Ruslan <11838981+feedmeapples@users.noreply.github.com> Date: Fri, 3 Feb 2023 20:31:47 -0500 Subject: [PATCH] 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 --- common/cluster/metadata.go | 2 ++ temporal/fx.go | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/common/cluster/metadata.go b/common/cluster/metadata.go index 463fbbf4ce7..4cabedc68a3 100644 --- a/common/cluster/metadata.go +++ b/common/cluster/metadata.go @@ -104,6 +104,8 @@ type ( InitialFailoverVersion int64 `yaml:"initialFailoverVersion"` // Address indicate the remote service address(Host:Port). Host can be DNS name. RPCAddress string `yaml:"rpcAddress"` + // Cluster ID allows to explicitly set the ID of the cluster. Optional. + ClusterID string `yaml:"-"` ShardCount int32 `yaml:"-"` // Ignore this field when loading config. // private field to track cluster information updates version int64 diff --git a/temporal/fx.go b/temporal/fx.go index 9f483af56ff..45f7c40cc54 100644 --- a/temporal/fx.go +++ b/temporal/fx.go @@ -662,11 +662,21 @@ func ApplyClusterMetadataConfigProvider( tag.Key("clusterInformation"), tag.ClusterName(clusterName), tag.IgnoredValue(clusterInfo)) + + // Only configure current cluster metadata from static config file continue } - // Only configure current cluster metadata from static config file - clusterId := uuid.New() + var clusterId string + if uuid.Parse(clusterInfo.ClusterID) == nil { + if clusterInfo.ClusterID != "" { + logger.Warn("Cluster Id in Cluster Metadata config is not a valid uuid. Generating a new Cluster Id") + } + clusterId = uuid.New() + } else { + clusterId = clusterInfo.ClusterID + } + applied, err := clusterMetadataManager.SaveClusterMetadata( ctx, &persistence.SaveClusterMetadataRequest{