ca: clean up unnecessary raft.Apply response checking

In d2ab767fef raftApply was changed to handle this check in
a single place, instad of having every caller check it. It looks like these few places
were missed when I did that clean up.

This commit removes the remaining resp.(error) checks, since they are all no-ops now.
This commit is contained in:
Daniel Nephin 2021-11-26 17:57:55 -05:00
parent 52f0853ff9
commit 59204598c8
1 changed files with 4 additions and 20 deletions

View File

@ -240,12 +240,9 @@ func (c *CAManager) initializeCAConfig() (*structs.CAConfiguration, error) {
Op: structs.CAOpSetConfig, Op: structs.CAOpSetConfig,
Config: config, Config: config,
} }
if resp, err := c.delegate.ApplyCARequest(&req); err != nil { if _, err := c.delegate.ApplyCARequest(&req); err != nil {
return nil, err return nil, err
} else if respErr, ok := resp.(error); ok {
return nil, respErr
} }
return config, nil return config, nil
} }
@ -564,17 +561,13 @@ func (c *CAManager) primaryInitialize(provider ca.Provider, conf *structs.CAConf
} }
// Store the root cert in raft // Store the root cert in raft
resp, err := c.delegate.ApplyCARequest(&structs.CARequest{ _, err = c.delegate.ApplyCARequest(&structs.CARequest{
Op: structs.CAOpSetRoots, Op: structs.CAOpSetRoots,
Index: idx, Index: idx,
Roots: []*structs.CARoot{rootCA}, Roots: []*structs.CARoot{rootCA},
}) })
if err != nil { if err != nil {
c.logger.Error("Raft apply failed", "error", err) return fmt.Errorf("raft apply failed: %w", err)
return err
}
if respErr, ok := resp.(error); ok {
return respErr
} }
c.setCAProvider(provider, rootCA) c.setCAProvider(provider, rootCA)
@ -776,9 +769,6 @@ func (c *CAManager) persistNewRootAndConfig(provider ca.Provider, newActiveRoot
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok {
return respErr
}
if respOk, ok := resp.(bool); ok && !respOk { if respOk, ok := resp.(bool); ok && !respOk {
return fmt.Errorf("could not atomically update roots and config") return fmt.Errorf("could not atomically update roots and config")
} }
@ -917,13 +907,10 @@ func (c *CAManager) primaryUpdateRootCA(newProvider ca.Provider, args *structs.C
// If the root didn't change, just update the config and return. // If the root didn't change, just update the config and return.
if root != nil && root.ID == newActiveRoot.ID { if root != nil && root.ID == newActiveRoot.ID {
args.Op = structs.CAOpSetConfig args.Op = structs.CAOpSetConfig
resp, err := c.delegate.ApplyCARequest(args) _, err := c.delegate.ApplyCARequest(args)
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok {
return respErr
}
// If the config has been committed, update the local provider instance // If the config has been committed, update the local provider instance
c.setCAProvider(newProvider, newActiveRoot) c.setCAProvider(newProvider, newActiveRoot)
@ -1021,9 +1008,6 @@ func (c *CAManager) primaryUpdateRootCA(newProvider ca.Provider, args *structs.C
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok {
return respErr
}
if respOk, ok := resp.(bool); ok && !respOk { if respOk, ok := resp.(bool); ok && !respOk {
return fmt.Errorf("could not atomically update roots and config") return fmt.Errorf("could not atomically update roots and config")
} }