Skip to content

Commit

Permalink
Allow setting cluster Id explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
feedmeapples committed Feb 2, 2023
1 parent dbeab31 commit f8bafed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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 the ID of the cluster. Optional.
ClusterID string `yaml:"clusterId"`
ShardCount int32 `yaml:"-"` // Ignore this field when loading config.
// private field to track cluster information updates
version int64
Expand Down
11 changes: 10 additions & 1 deletion temporal/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,20 @@ 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()
if clusterInfo.ClusterID != "" {
if uuid.Parse(clusterInfo.ClusterID) == nil {
return config.ClusterMetadata, config.Persistence, fmt.Errorf("invalid cluster id: %v", clusterInfo.ClusterID)
}

clusterId = clusterInfo.ClusterID
}

applied, err := clusterMetadataManager.SaveClusterMetadata(
ctx,
&persistence.SaveClusterMetadataRequest{
Expand Down

0 comments on commit f8bafed

Please sign in to comment.