Files
Pulse/internal/monitoring
rcourtman fea6e199fb Read guest filesystems about once a minute (#3911)
Refs #2439. This lowers the odds of the collision; it does not fix the
issue, and the stop-Pulse advice stays.

## Why

A guest-agent command caught by a freeze can time out in Proxmox and
leave a stale reply that the thaw reads as `got wrong command id`. A
native test on 4 November reproduced that error. The lock and
replication checks can't stop a read already running when a freeze
starts, so exposure scales with how often commands go out. `get-fsinfo`
was the only one sent every poll.

## What changes

A completed `get-fsinfo` reply is reused for 55 seconds, so 10-second
polls read about once a minute. Guest disk figures and disk alerts can
therefore lag by up to a minute.

| Situation | Behaviour |
| --- | --- |
| Lock or replication | No command, as before. A lock outranks a young
reply. |
| Failed or deferred read | Never reused, retried next poll |
| Empty or unusable reply | Reused, since asking again only adds
commands |
| Stopped guest, unavailable agent, falling uptime | Reply dropped, so
the guest gets its own read |

## Fresh and reused readings

- **Stays current:** `DiskStatusReason` stays empty, so disk alerts keep
evaluating a reused reading. A change reaches them at the next read.
- **Keeps the read's time:** `DiskObservation.ObservedAt` and
`GuestAgentEvidence` don't move, so retention still ends ten minutes
after the read.
- **Doesn't prove the agent answered:** without a status reply, a reuse
doesn't report the agent as available.

## History still gets a point per poll

The series now steps about once a minute, as cached meminfo already
does. I first expected to write only fresh reads, but
`getGuestDrawerHistorySegments` breaks a series wherever another series
in its panel has a reading and it does not. Disk would turn into
isolated dots with "Missing observations: Disk". Retained `prev-`
readings stay History gaps as before.

## Verification

- `go test ./internal/monitoring/ ./pkg/proxmox/` passes on pulse-dev.
- 16 of 17 mutations, each removing or altering a safeguard, made the
new tests fail. The survivor only changes `>=` to `>` at the exact TTL
boundary.
- Fixture clients only. No native run has measured the effect on the
collision rate.

## Not covered

- Guests with a linked Pulse agent still send `get-fsinfo`, even though
the agent's disks are preferred.
- The per-node collector in `monitor_polling_vm.go` writes
`vm.Disk.Usage` to History without the `DiskStatusReason` check the
cluster path has. That predates this change.

The `Contract-Neutral` trailer covers `agent-lifecycle.md` only:
`monitor.go` and `monitor_agents.go` belong to that subsystem too, but
Pulse agent lifecycle is unchanged. The contract note is in
`monitoring.md`.
2026-11-04 20:55:27 +00:00
..
2026-03-18 16:06:30 +00:00
2026-07-11 18:25:17 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00