Skip to content

Commit

Permalink
keyring: filter by region before checking version (#14901)
Browse files Browse the repository at this point in the history
In #14821 we fixed a panic that can happen if a leadership election happens in
the middle of an upgrade. That fix checks that all servers are at the minimum
version before initializing the keyring (which blocks evaluation processing
during trhe upgrade). But the check we implemented is over the serf membership,
which includes servers in any federated regions, which don't necessarily have
the same upgrade cycle.

Filter the version check by the leader's region.

Also bump up log levels of major keyring operations
  • Loading branch information
tgross authored Oct 17, 2022
1 parent 57dc7c2 commit f6838f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/14901.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
keyring: Fixed a bug where keyring initialization is blocked by un-upgraded federated regions
```
4 changes: 2 additions & 2 deletions nomad/encrypter.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ START:
// new leader has not yet replicated the key from
// the old leader before the transition. Ask all
// the other servers if they have it.
krr.logger.Debug("failed to fetch key from current leader",
krr.logger.Warn("failed to fetch key from current leader, trying peers",
"key", keyID, "error", err)
getReq.AllowStale = true
for _, peer := range krr.getAllPeers() {
Expand All @@ -494,7 +494,7 @@ START:
krr.logger.Error("failed to add key", "key", keyID, "error", err)
goto ERR_WAIT
}
krr.logger.Trace("added key", "key", keyID)
krr.logger.Info("added key", "key", keyID)
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,15 @@ func (s *Server) initializeKeyring(stopCh <-chan struct{}) {
return
default:
}
if ServersMeetMinimumVersion(s.serf.Members(), minVersionKeyring, true) {

members := s.serf.Members()
regionMembers := []serf.Member{}
for _, member := range members {
if member.Tags["region"] == s.Region() {
regionMembers = append(regionMembers, member)
}
}
if ServersMeetMinimumVersion(regionMembers, minVersionKeyring, true) {
break
}
}
Expand Down

0 comments on commit f6838f6

Please sign in to comment.