A standby's admin API is the leader's
The console and ctl on a standby showed its own empty view: nodes and replicas live in the leader's memory. A standby now passes /api/ to the leader over the agent port, with the cluster's certificates both ways; the leader answers only a certificate naming a control plane the store lists, and only while it leads. Control plane certificates are issued for client use as well, and server add reissues older ones. An agent's reconnect backoff starts again after a session that worked, so each failover it lives through no longer makes the next one slower. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
adef25d709
commit
1d1409faad
12 files changed
+510
-13
No files matched your search
@@ -1162,8 +1162,18 @@ func (a *API) removeModel(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, Removed{Removed: name})
|
||||
}
|
||||
|
||||
func (a *API) summary(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusOK, a.Summary())
|
||||
func (a *API) summary(w http.ResponseWriter, r *http.Request) {
|
||||
s := a.Summary()
|
||||
// Asked through a standby, which passes on the console's questions to
|
||||
// the leader: "this one" is the standby the console is on.
|
||||
if by := r.Header.Get("X-Llmgw-Forwarded-By"); by != "" && len(s.ControlPlanes.Members) > 0 {
|
||||
members := slices.Clone(s.ControlPlanes.Members)
|
||||
for i := range members {
|
||||
members[i].This = members[i].Name == by
|
||||
}
|
||||
s.ControlPlanes.Members = members
|
||||
}
|
||||
writeJSON(w, http.StatusOK, s)
|
||||
}
|
||||
|
||||
func (a *API) explainPlacement(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -231,6 +231,10 @@ func (c *Controller) SetLeadership(l *Leadership) {
|
||||
c.rec.SetLeadership(l)
|
||||
}
|
||||
|
||||
// Leadership is what SetLeadership set; nil when there is nobody to compete
|
||||
// with.
|
||||
func (c *Controller) Leadership() *Leadership { return c.lead }
|
||||
|
||||
// IsLeader reports whether this process is placing work. True when leadership
|
||||
// was never configured, because then there is nobody to compete with.
|
||||
func (c *Controller) IsLeader() bool { return c.lead == nil || c.lead.IsLeader() }
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -183,3 +184,16 @@ func newOwnerID() string {
|
||||
}
|
||||
return host + "-" + hex.EncodeToString(b[:])
|
||||
}
|
||||
|
||||
// ControlRole is the lease's name in the store, for readers that ask who
|
||||
// holds it without competing.
|
||||
const ControlRole = controlRole
|
||||
|
||||
// HolderName is the machine an owner id names: the hostname it was made
|
||||
// from, without the random part.
|
||||
func HolderName(owner string) string {
|
||||
if i := strings.LastIndexByte(owner, '-'); i > 0 {
|
||||
return owner[:i]
|
||||
}
|
||||
return owner
|
||||
}
|
||||
Reference in new issue
Block a user