Do not attempt to write a new TLS keyring at startup if raft is already setup (#17079)

This commit is contained in:
Nick Cabatoff 2022-09-09 12:19:57 -04:00 committed by GitHub
parent 5b5699e9b0
commit 3075c5bd65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 54 deletions

2
changelog/17079.txt Normal file
View file

@ -0,0 +1,2 @@
```release-note:bug
storage/raft: Fix error writing raft TLS keyring during follower joins

View file

@ -73,14 +73,15 @@ func (c *Core) startRaftBackend(ctx context.Context) (retErr error) {
return nil return nil
} }
var creating bool
var raftTLS *raft.TLSKeyring
if !raftBackend.Initialized() {
// Retrieve the raft TLS information // Retrieve the raft TLS information
raftTLSEntry, err := c.barrier.Get(ctx, raftTLSStoragePath) raftTLSEntry, err := c.barrier.Get(ctx, raftTLSStoragePath)
if err != nil { if err != nil {
return err return err
} }
var creating bool
var raftTLS *raft.TLSKeyring
switch raftTLSEntry { switch raftTLSEntry {
case nil: case nil:
// If this is HA-only and no TLS keyring is found, that means the // If this is HA-only and no TLS keyring is found, that means the
@ -140,6 +141,7 @@ func (c *Core) startRaftBackend(ctx context.Context) (retErr error) {
}); err != nil { }); err != nil {
return err return err
} }
}
defer func() { defer func() {
if retErr != nil { if retErr != nil {