ca: Only initialize clusterID in the primary

The secondary must get the clusterID from the primary
This commit is contained in:
Daniel Nephin 2021-11-05 18:08:44 -04:00
parent 3173582b75
commit 69ad7c0544
2 changed files with 2 additions and 3 deletions

View File

@ -213,7 +213,8 @@ func (c *CAManager) initializeCAConfig() (*structs.CAConfiguration, error) {
}
if config == nil {
config = c.serverConf.CAConfig
if config.ClusterID == "" {
if c.serverConf.Datacenter == c.serverConf.PrimaryDatacenter && config.ClusterID == "" {
id, err := uuid.GenerateUUID()
if err != nil {
return nil, err

View File

@ -180,8 +180,6 @@ func (s *Store) caSetConfigTxn(idx uint64, tx WriteTxn, config *structs.CAConfig
if prev != nil {
existing := prev.(*structs.CAConfiguration)
config.CreateIndex = existing.CreateIndex
// Allow the ClusterID to change if it's provided by an internal operation, such
// as a primary datacenter being switched to secondary mode.
if config.ClusterID == "" {
config.ClusterID = existing.ClusterID
}