Every agent file on the cluster named its own node, its own address, the path to llama-server and two weight directories — different on every node, kept true by hand, and not true: node05 carried "ram: 32g" beside a measured 31 GB, looked for weights in an empty directory while fetching them into another, and the other four never looked in theirs at all, so four nodes reported no disk. Growing a node's RAM would have gone unnoticed, because memory was read once, at registration. The agent now finds these out. Its id is the hostname, which is also the certificate's common name. Its address is the one on the route to the control plane, which the kernel picks for a UDP dial without sending anything. llama-server is looked for on PATH and then where release archives are unpacked. A missing nvidia-smi is a node without NVIDIA cards rather than a failed discovery — which also cut discovery short before InfiniBand on every CPU node not told to skip GPUs. Fetched weights land in /var/lib/llmgw-weights by default, and wherever they land is always looked in. Memory is read on every heartbeat, and installed engines are probed again each minute and sent when they change, so a VM given more RAM or a node given vLLM becomes a candidate without anyone restarting its agent. The control plane logs both changes, since "the node now qualifies" is the answer to why a model placed an hour after it was asked for. What is written still wins. The agent file shrinks to the control plane's addresses and the TLS files, the same on every node; onboarding writes only the overrides it was given. What cannot be found stays configuration: which fabric an adapter is on, because OpenSM's default prefix is the same on all of them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2cae92d113
commit
20deb22dfa
14 files changed
+552
-134
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package agentsvc
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"testing"
|
||||
|
||||
llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1"
|
||||
@@ -11,7 +12,8 @@ import (
|
||||
func nodeWith(s *Service, n inventory.Node) { s.inv.Upsert(n) }
|
||||
|
||||
func newTestService() *Service {
|
||||
return &Service{inv: inventory.NewStore(), conns: map[string]*conn{}}
|
||||
return &Service{inv: inventory.NewStore(), conns: map[string]*conn{},
|
||||
log: slog.New(slog.DiscardHandler)}
|
||||
}
|
||||
|
||||
func TestDiskIsRefreshedWhileTheAgentRuns(t *testing.T) {
|
||||
@@ -112,3 +114,44 @@ func TestAHeartbeatAboutNothingChangesNothing(t *testing.T) {
|
||||
t.Errorf("disk changed: %d", free)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHeartbeatCarriesMemoryAddedToARunningNode(t *testing.T) {
|
||||
// Read once at registration, a node that was given 32 GB went on looking
|
||||
// like the 7 GB machine it had been, and every model that needed the
|
||||
// difference stayed unplaced until somebody restarted its agent.
|
||||
s := newTestService()
|
||||
nodeWith(s, inventory.Node{ID: "n1", State: inventory.Ready, MemoryTotalMB: 7 * 1024})
|
||||
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{NodeId: "n1", MemoryTotalMb: 32 * 1024})
|
||||
|
||||
if n, _ := s.inv.Get("n1"); n.MemoryTotalMB != 32*1024 {
|
||||
t.Errorf("memory is %d MB, expected the 32 GB the node now has", n.MemoryTotalMB)
|
||||
}
|
||||
|
||||
// Zero is an agent that could not read it, not a node that lost its RAM.
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{NodeId: "n1"})
|
||||
if n, _ := s.inv.Get("n1"); n.MemoryTotalMB != 32*1024 {
|
||||
t.Errorf("a heartbeat without memory erased it: %d", n.MemoryTotalMB)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHeartbeatCarriesAnEngineInstalledAfterRegistration(t *testing.T) {
|
||||
s := newTestService()
|
||||
nodeWith(s, inventory.Node{ID: "n1", State: inventory.Ready,
|
||||
EngineVersions: map[string]string{"llamacpp": "unknown"}})
|
||||
|
||||
// Unchanged engines are not resent, and silence must not clear them.
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{NodeId: "n1", MemoryTotalMb: 1024})
|
||||
if n, _ := s.inv.Get("n1"); len(n.EngineVersions) != 1 {
|
||||
t.Fatalf("engines changed without being reported: %v", n.EngineVersions)
|
||||
}
|
||||
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{
|
||||
NodeId: "n1", EnginesChanged: true,
|
||||
EngineVersions: map[string]string{"llamacpp": "unknown", "vllm": "unknown"},
|
||||
})
|
||||
n, _ := s.inv.Get("n1")
|
||||
if _, ok := n.EngineVersions["vllm"]; !ok {
|
||||
t.Errorf("the newly installed engine is not known: %v", n.EngineVersions)
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net/http"
|
||||
"slices"
|
||||
"sync"
|
||||
@@ -269,7 +270,9 @@ func (s *Service) applyHeartbeat(nodeID string, hb *llmgwv1.Heartbeat) {
|
||||
used := hb.GetGpuMemoryUsedMb()
|
||||
problems := hb.GetNewProblems()
|
||||
storage := hb.GetStorage()
|
||||
if len(used) == 0 && len(problems) == 0 && len(storage) == 0 && !hb.GetWeightsChanged() {
|
||||
memMB := int(hb.GetMemoryTotalMb())
|
||||
if len(used) == 0 && len(problems) == 0 && len(storage) == 0 &&
|
||||
!hb.GetWeightsChanged() && memMB == 0 && !hb.GetEnginesChanged() {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -316,6 +319,26 @@ func (s *Service) applyHeartbeat(nodeID string, hb *llmgwv1.Heartbeat) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// RAM and engines change under a running agent too: memory added to a VM,
|
||||
// an engine installed this afternoon. Said in the log when they do, because
|
||||
// "the node now qualifies" is the answer to why a model placed an hour after
|
||||
// it was asked for, and "the node no longer does" is the answer to why one
|
||||
// stopped placing.
|
||||
if memMB > 0 && memMB != n.MemoryTotalMB {
|
||||
s.log.Info("node memory changed", "node", nodeID,
|
||||
"from_mb", n.MemoryTotalMB, "to_mb", memMB)
|
||||
n.MemoryTotalMB = memMB
|
||||
}
|
||||
if hb.GetEnginesChanged() {
|
||||
vers := maps.Clone(hb.GetEngineVersions())
|
||||
if !maps.Equal(vers, n.EngineVersions) {
|
||||
s.log.Info("node engines changed", "node", nodeID,
|
||||
"from", slices.Sorted(maps.Keys(n.EngineVersions)),
|
||||
"to", slices.Sorted(maps.Keys(vers)))
|
||||
}
|
||||
n.EngineVersions = vers
|
||||
}
|
||||
s.inv.Upsert(n)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user