Browse Source

ca: Only initialize clusterID in the primary

The secondary must get the clusterID from the primary
pull/11514/head
Daniel Nephin 3 years ago
parent
commit
d9110136f2
  1. 3
      agent/consul/leader_connect_ca.go
  2. 2
      agent/consul/state/connect_ca.go

3
agent/consul/leader_connect_ca.go

@ -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

2
agent/consul/state/connect_ca.go

@ -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
}

Loading…
Cancel
Save