1
0
Fork 0

Merge pull request #1437 from rqlite/nodes-timeout

Use top-level timeout check for nodes/
master
Philip O'Toole 10 months ago committed by GitHub
commit b3ba19c0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,6 +49,7 @@ When officially released 8.0 will support (mostly) seamless upgrades from the 7.
- [PR #1420](https://github.com/rqlite/rqlite/pull/1420), [PR #1431](https://github.com/rqlite/rqlite/pull/1431): Nodes join a cluster using the Raft address, not the HTTP API.
- [PR #1426](https://github.com/rqlite/rqlite/pull/1426): 'go mod' updates, including moving to Raft 1.6.
- [PR #1430](https://github.com/rqlite/rqlite/pull/1430): Check that any supplied Join addresses are not HTTP servers.
- [PR #1437](https://github.com/rqlite/rqlite/pull/1437): Actually timeout if needed during `nodes/` access. Fixes [issue #1435](https://github.com/rqlite/rqlite/issues/1435). Thanks @dwco-z
## 7.21.4 (July 8th 2023)
### Implementation changes and bug fixes

@ -39,16 +39,31 @@ func NewNodeFromServer(s *store.Server) *Node {
// occurs, the Error field will be populated.
func (n *Node) Test(ga GetAddresser, leaderAddr string, timeout time.Duration) {
start := time.Now()
n.Time = time.Since(start).Seconds()
timer := time.NewTimer(timeout)
defer timer.Stop()
done := make(chan struct{})
go func() {
defer close(done)
apiAddr, err := ga.GetNodeAPIAddr(n.Addr, timeout)
if err != nil {
n.Error = err.Error()
n.Reachable = false
return
}
n.Time = time.Since(start).Seconds()
n.APIAddr = apiAddr
n.Reachable = true
n.Leader = n.Addr == leaderAddr
}()
select {
case <-timer.C:
n.Error = "timeout"
return
case <-done:
return
}
}
type Nodes []*Node

Loading…
Cancel
Save