Added RPC calls to get the status from the master on non-master nodes
Release / release (push) Has been cancelled

This commit is contained in:
2026-05-14 00:00:58 +00:00
parent 46abc09b11
commit bd437f49e4
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ func (c *controlServer) handleConn(ctx context.Context, conn net.Conn) {
func (c *controlServer) dispatch(ctx context.Context, req CtrlRequest) CtrlResponse {
switch req.Method {
case CtrlStatus:
return ok(c.d.buildStatus())
return ok(c.d.buildStatusForCLI(ctx))
case CtrlMutate:
var body MutateBody
+29
View File
@@ -113,6 +113,35 @@ func (d *Daemon) registerHandlers() {
})
}
// buildStatusForCLI is what the local control plane returns to `qu
// status`. Peers, quorum, and term come from the local view; check
// state is fetched from the master because the aggregator only runs
// there. If the master is unknown or unreachable, falls back to the
// local view (which will show "unknown" for every check).
func (d *Daemon) buildStatusForCLI(ctx context.Context) transport.StatusResponse {
local := d.buildStatus()
if d.quorum.IsMaster() {
return local
}
masterID := d.quorum.Master()
if masterID == "" {
return local
}
addr := d.addressOf(masterID)
if addr == "" {
return local
}
callCtx, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
var remote transport.StatusResponse
if err := d.client.Call(callCtx, masterID, addr, transport.MethodStatus, transport.StatusRequest{}, &remote); err != nil {
d.logger.Printf("status: fetch from master %s: %v", masterID, err)
return local
}
local.Checks = remote.Checks
return local
}
// buildStatus is shared by both the inter-node Status RPC handler and
// the local control plane's "status" command.
func (d *Daemon) buildStatus() transport.StatusResponse {