The memory is measured after the agent reaches its control plane
CI / test (push) Successful in 9m5s
CI / test (push) Successful in 9m5s
Measuring it in the startup scan held every agent half a second or more before registering, which on a shared CI runner was past the failover tests' wait. Now it runs once a process, in the background, the first time it is asked for, and Heartbeat.mem_bandwidth_gbs carries it when known; the control plane keeps the last figure and a heartbeat without one leaves it. The agent's tests do not measure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
84444e71c8
commit
e70d6caa2f
6 files changed
+83
-8
No files matched your search
@@ -325,3 +325,18 @@ func TestAProblemOnANodeWithoutGPUsDoesNotPanic(t *testing.T) {
|
||||
t.Fatal("the node is gone")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHeartbeatCarriesTheMemorysMeasuredSpeed(t *testing.T) {
|
||||
// Measured in the background after the agent starts, so it arrives in a
|
||||
// heartbeat, not in the registration.
|
||||
s := newTestService()
|
||||
nodeWith(s, inventory.Node{ID: "n1", State: inventory.Ready, MemoryTotalMB: 7 * 1024})
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{NodeId: "n1", MemBandwidthGbs: 41.9})
|
||||
if n, _ := s.inv.Get("n1"); n.Host.MemBandwidthGBs != 41.9 {
|
||||
t.Errorf("bandwidth %v, want 41.9", n.Host.MemBandwidthGBs)
|
||||
}
|
||||
s.applyHeartbeat("n1", &llmgwv1.Heartbeat{NodeId: "n1"})
|
||||
if n, _ := s.inv.Get("n1"); n.Host.MemBandwidthGBs != 41.9 {
|
||||
t.Errorf("a heartbeat without it erased it: %v", n.Host.MemBandwidthGBs)
|
||||
}
|
||||
}
|
||||
@@ -547,10 +547,11 @@ func (s *Service) applyHeartbeat(nodeID string, hb *llmgwv1.Heartbeat) {
|
||||
storage := hb.GetStorage()
|
||||
memMB := int(hb.GetMemoryTotalMb())
|
||||
cpus := int(hb.GetCpuCount())
|
||||
bw := hb.GetMemBandwidthGbs()
|
||||
if len(used) == 0 && len(foreign) == 0 && len(problems) == 0 && len(storage) == 0 &&
|
||||
!hb.GetWeightsChanged() && memMB == 0 && cpus == 0 && !hb.GetEnginesChanged() &&
|
||||
!hb.GetProvisionChanged() && hb.GetLoad() == nil && len(hb.GetIbPorts()) == 0 &&
|
||||
!hb.GetFabricsChanged() && len(hb.GetGpuFabric()) == 0 && hb.GetImex() == nil {
|
||||
!hb.GetFabricsChanged() && len(hb.GetGpuFabric()) == 0 && hb.GetImex() == nil && bw == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -622,6 +623,9 @@ func (s *Service) applyHeartbeat(nodeID string, hb *llmgwv1.Heartbeat) {
|
||||
"from_mb", n.MemoryTotalMB, "to_mb", memMB)
|
||||
n.MemoryTotalMB = memMB
|
||||
}
|
||||
if bw > 0 {
|
||||
n.Host.MemBandwidthGBs = bw
|
||||
}
|
||||
if cpus > 0 && cpus != n.CPUCount {
|
||||
if n.CPUCount > 0 {
|
||||
s.log.Info("node CPUs changed", "node", nodeID, "from", n.CPUCount, "to", cpus)
|
||||
|
||||
Reference in new issue
Block a user