The floating address is read each time the summary is asked
server add records it after restarting the new control plane, which then never named it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1d1409faad
commit
c2b4985abe
2 files changed
+13
-6
No files matched your search
@@ -25,8 +25,9 @@ const floatingPath = "/etc/llmgw/floating"
|
|||||||
// held it last and says nothing about a standby that has stopped — and a
|
// held it last and says nothing about a standby that has stopped — and a
|
||||||
// standby that is not there is the thing worth seeing before it is needed.
|
// standby that is not there is the thing worth seeing before it is needed.
|
||||||
type controlPlaneProbe struct {
|
type controlPlaneProbe struct {
|
||||||
st *store.DB
|
st *store.DB
|
||||||
self string
|
self string
|
||||||
|
// floating is the file the floating address is recorded in.
|
||||||
floating string
|
floating string
|
||||||
client *http.Client
|
client *http.Client
|
||||||
// leaderURL is where a host is asked; tests point it elsewhere.
|
// leaderURL is where a host is asked; tests point it elsewhere.
|
||||||
@@ -65,7 +66,9 @@ func (p *controlPlaneProbe) Status() adminapi.ControlPlanes {
|
|||||||
p.at, p.last = time.Now(), adminapi.ControlPlanes{}
|
p.at, p.last = time.Now(), adminapi.ControlPlanes{}
|
||||||
return p.last
|
return p.last
|
||||||
}
|
}
|
||||||
out := adminapi.ControlPlanes{Members: make([]adminapi.ControlPlane, len(cps)), Floating: p.floating}
|
// Read each time: server add writes it after this process may have
|
||||||
|
// started.
|
||||||
|
out := adminapi.ControlPlanes{Members: make([]adminapi.ControlPlane, len(cps)), Floating: floatingAddress(p.floating)}
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i, cp := range cps {
|
for i, cp := range cps {
|
||||||
host := cp.URL
|
host := cp.URL
|
||||||
@@ -75,8 +78,8 @@ func (p *controlPlaneProbe) Status() adminapi.ControlPlanes {
|
|||||||
out.Members[i] = adminapi.ControlPlane{Name: cp.Name, Address: host, This: cp.Name == p.self}
|
out.Members[i] = adminapi.ControlPlane{Name: cp.Name, Address: host, This: cp.Name == p.self}
|
||||||
wg.Go(func() { out.Members[i].State = p.ask(ctx, host) })
|
wg.Go(func() { out.Members[i].State = p.ask(ctx, host) })
|
||||||
}
|
}
|
||||||
if p.floating != "" {
|
if out.Floating != "" {
|
||||||
wg.Go(func() { out.FloatingUp = p.ask(ctx, p.floating) == "leading" })
|
wg.Go(func() { out.FloatingUp = p.ask(ctx, out.Floating) == "leading" })
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
p.at, p.last = time.Now(), out
|
p.at, p.last = time.Now(), out
|
||||||
|
|||||||
@@ -76,7 +76,11 @@ func TestTheProbeAsksEachControlPlaneWhetherItLeads(t *testing.T) {
|
|||||||
}
|
}
|
||||||
at := map[string]string{"10.0.0.1": leading.URL, "10.0.0.2": standby.URL, "10.0.0.3": gone.URL, "10.0.0.161": leading.URL}
|
at := map[string]string{"10.0.0.1": leading.URL, "10.0.0.2": standby.URL, "10.0.0.3": gone.URL, "10.0.0.161": leading.URL}
|
||||||
p := newControlPlaneProbe(st, ":8080")
|
p := newControlPlaneProbe(st, ":8080")
|
||||||
p.self, p.floating = "two", "10.0.0.161"
|
floating := filepath.Join(t.TempDir(), "floating")
|
||||||
|
if err := os.WriteFile(floating, []byte("10.0.0.161/24\n"), 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
p.self, p.floating = "two", floating
|
||||||
p.leaderURL = func(host string) string { return at[host] + "/leader" }
|
p.leaderURL = func(host string) string { return at[host] + "/leader" }
|
||||||
|
|
||||||
s := p.Status()
|
s := p.Status()
|
||||||
|
|||||||
Reference in new issue
Block a user