backport of commit 5d97159f05e581c0e5f14be9e2e3f8ac3b733091 (#21886)
Co-authored-by: Tom Proctor <tomhjp@users.noreply.github.com>
This commit is contained in:
parent
7f6d4dc70b
commit
9c43e232d2
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
serviceregistration: Fix bug where multiple nodes in a secondary cluster could be labelled active after updating the cluster's primary
|
||||||
|
```
|
20
vault/ha.go
20
vault/ha.go
|
@ -710,6 +710,13 @@ func (c *Core) waitForLeadership(newLeaderCh chan func(), manualStepDownCh, stop
|
||||||
c.heldHALock = nil
|
c.heldHALock = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Advertise ourselves as a standby.
|
||||||
|
if c.serviceRegistration != nil {
|
||||||
|
if err := c.serviceRegistration.NotifyActiveStateChange(false); err != nil {
|
||||||
|
c.logger.Warn("failed to notify standby status", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we are stopped return, otherwise unlock the statelock
|
// If we are stopped return, otherwise unlock the statelock
|
||||||
if stopped {
|
if stopped {
|
||||||
return
|
return
|
||||||
|
@ -1133,18 +1140,7 @@ func (c *Core) cleanLeaderPrefix(ctx context.Context, uuid string, leaderLostCh
|
||||||
// clearLeader is used to clear our leadership entry
|
// clearLeader is used to clear our leadership entry
|
||||||
func (c *Core) clearLeader(uuid string) error {
|
func (c *Core) clearLeader(uuid string) error {
|
||||||
key := coreLeaderPrefix + uuid
|
key := coreLeaderPrefix + uuid
|
||||||
err := c.barrier.Delete(context.Background(), key)
|
return c.barrier.Delete(context.Background(), key)
|
||||||
|
|
||||||
// Advertise ourselves as a standby
|
|
||||||
if c.serviceRegistration != nil {
|
|
||||||
if err := c.serviceRegistration.NotifyActiveStateChange(false); err != nil {
|
|
||||||
if c.logger.IsWarn() {
|
|
||||||
c.logger.Warn("failed to notify standby status", "error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) SetNeverBecomeActive(on bool) {
|
func (c *Core) SetNeverBecomeActive(on bool) {
|
||||||
|
|
Loading…
Reference in New Issue