Skip to content

Commit

Permalink
Allow setting cluster Id explicitly (#3883)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
feedmeapples authored Feb 4, 2023
1 parent 20a5ce3 commit 3ade263
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/cluster/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions temporal/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 3ade263

Please sign in to comment.