Forward autopilot state reqs, avoid self-dialing (#15493)

Make sure that autopilot is disabled when we step down from active node state.  Forward autopilot state requests to the active node.  Avoid self-dialing due to stale advertisement.
This commit is contained in:
Nick Cabatoff 2022-05-18 14:50:18 -04:00 committed by GitHub
parent af2c9784df
commit bc9f69af2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 4 deletions

3
changelog/15493.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
storage/raft: Forward autopilot state requests on perf standbys to active node.
```

2
go.mod
View File

@ -54,6 +54,7 @@ require (
github.com/google/go-cmp v0.5.6
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-metrics-stackdriver v0.2.0
github.com/google/tink/go v1.4.0
github.com/hashicorp/cap v0.1.1
github.com/hashicorp/consul-template v0.29.0
github.com/hashicorp/consul/api v1.12.0
@ -274,7 +275,6 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/tink/go v1.4.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect

1
go.sum
View File

@ -885,7 +885,6 @@ github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 h1:p4AKXPPS24tO8Wc8i1gLvSKdmk
github.com/hashicorp/go-secure-stdlib/mlock v0.1.2/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.2/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.4/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.5 h1:MBgwAFPUbfuI0+tmDU/aeM1MARvdbqWmiieXIalKqDE=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.5/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
github.com/hashicorp/go-secure-stdlib/password v0.1.1 h1:6JzmBqXprakgFEHwBgdchsjaA9x3GyjdI568bXKxa60=

View File

@ -499,6 +499,7 @@ func (b *RaftBackend) StopAutopilot() {
return
}
b.autopilot.Stop()
b.autopilot = nil
b.followerHeartbeatTicker.Stop()
}

View File

@ -185,6 +185,15 @@ func (c *Core) Leader() (isLeader bool, leaderAddr, clusterAddr string, err erro
oldAdv = true
}
// At the top of this function we return early when we're the active node.
// If we're not the active node, and there's a stale advertisement pointing
// to ourself, there's no point in paying any attention to it. And by
// disregarding it, we can avoid a panic in raft tests using the Inmem network
// layer when we try to connect back to ourself.
if adv.ClusterAddr == c.ClusterAddr() && adv.RedirectAddr == c.redirectAddr {
return false, "", "", nil
}
if !oldAdv {
c.logger.Debug("parsing information for new active node", "active_cluster_addr", adv.ClusterAddr, "active_redirect_addr", adv.RedirectAddr)

View File

@ -152,8 +152,9 @@ func (b *SystemBackend) raftStoragePaths() []*framework.Path {
Pattern: "storage/raft/autopilot/state",
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.verifyDROperationTokenOnSecondary(b.handleStorageRaftAutopilotState(), false),
Summary: "Returns the state of the raft cluster under integrated storage as seen by autopilot.",
Callback: b.verifyDROperationTokenOnSecondary(b.handleStorageRaftAutopilotState(), false),
Summary: "Returns the state of the raft cluster under integrated storage as seen by autopilot.",
ForwardPerformanceStandby: true,
},
},