Avoid raft change when no config is provided on CAmanager
- This avoids a change to the raft store when no roots or config are provided to persistNewRootAndConfig
This commit is contained in:
parent
c60e04e086
commit
2ca00df0d8
|
@ -693,7 +693,7 @@ func (c *CAManager) persistNewRootAndConfig(provider ca.Provider, newActiveRoot
|
|||
return fmt.Errorf("local CA not initialized yet")
|
||||
}
|
||||
// Exit early if the change is a no-op.
|
||||
if newActiveRoot == nil && config != nil && config.Provider == storedConfig.Provider && reflect.DeepEqual(config.Config, storedConfig.Config) {
|
||||
if !shouldPersistNewRootAndConfig(newActiveRoot, storedConfig, config) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -758,6 +758,17 @@ func (c *CAManager) persistNewRootAndConfig(provider ca.Provider, newActiveRoot
|
|||
return nil
|
||||
}
|
||||
|
||||
func shouldPersistNewRootAndConfig(newActiveRoot *structs.CARoot, oldConfig, newConfig *structs.CAConfiguration) bool {
|
||||
if newActiveRoot != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if newConfig == nil {
|
||||
return false
|
||||
}
|
||||
return newConfig.Provider == oldConfig.Provider && reflect.DeepEqual(newConfig.Config, oldConfig.Config)
|
||||
}
|
||||
|
||||
func (c *CAManager) UpdateConfiguration(args *structs.CARequest) (reterr error) {
|
||||
// Attempt to update the state first.
|
||||
oldState, err := c.setState(caStateReconfig, true)
|
||||
|
|
Loading…
Reference in New Issue