Commit Graph

26 Commits

Author SHA1 Message Date
rcourtman
d87938bb24 Keep PBS job alerts through outages and partial reads
A PBS outage removed the datastore from a poll and stored the instance
without job results, so every failed-job alert cleared and fired again
when PBS returned. Job incidents now need two polls that see success
before recovering, so a missing datastore reads as unknown, and a failed
poll keeps the last job results so the carry survives the outage.

Only a failed job-list read now makes a family unreadable; task-history
trouble no longer keeps a removed job's failure alive. Recovery is judged
from the run's own status, so a success first seen after its next
schedule passed still clears the carry. Carried failures stay in memory:
a restart forgets them until PBS reports the job again.
2026-11-03 12:50:22 +00:00
rcourtman
2bafa37d5b Read PBS job status the way Proxmox does
PBS records a failed run as the bare error message. Matching substrings called "broken pipe" a success, which also cleared a carried failure, and left failures without "fail" or "error" in them unknown, so they never alerted. Exactly OK is success, a WARNINGS: prefix a warning, unknown unknown, and any other status a failure, as in proxmox-widget-toolkit parse_task_status.
2026-11-03 11:27:48 +00:00
rcourtman
24c9bfb8f1 Alert on failed PBS datastore jobs, apart from guest health
A PBS sync that failed after a successful backup left everything green
and raised nothing (#1815). A failed sync, verify, prune or GC run is a
problem with the datastore, not the guest, so each PBS datastore now
carries a pbs_job_failed incident per job whose newest run failed. The
existing incident pipeline turns it into a warning alert on that
datastore. Backup health lists the same failures under a Datastore jobs
heading, and guest counts are unchanged.

The poller now carries a job's last completed failure through polls
that report no newer outcome (a run in progress, an overdue job, a
failed read), so the alert neither flaps nor clears early. Jobs are
keyed by family as well as id, and a failed last run outranks overdue.
Mock PBS servers report job results, with one failed sync.
2026-11-03 10:30:02 +00:00
rcourtman
c86ca8d308 Keep re-read backups protected when one storage is unreadable
One enabled but unreachable PBS storage on one PVE node marked the whole
connection's backup history partial, and posture then refused Protected
to every guest on it. On a real instance that showed 47 of 49 guests as
"attention" although their fresh, verified backups sat on storages that
read fine, and the Backups page never said which storage was the cause.

A partial collection still confirms what it re-read: collectors renew a
point's evidence only for rows the poll returned, stamped with that poll's
observation time. Posture now counts a point as supported under partial
history when its evidence is no older than the latest observation for its
provider scope. A point retained from an unread scope keeps its older
evidence and may have been pruned since, so it still never supports
protection; neither do backfilled migration evidence or denied,
unavailable or unknown history. A supported current backup is no longer
withdrawn because another source is partial, matching the existing rule
for unreadable sources.

PVE and PBS observations now also name what went unread (node, storage,
datastore namespace discovery, namespace), persisted on the observation
row and carried on each provider state. Explanations name the scopes, and
the Backups page shows one line naming the unreadable storage and what to
check. The names explain the gap only; confirmation never depends on them.

Tests that asserted "no guest is protected under a partial poll" now
assert that only guests whose backup the poll re-read are protected, with
partial coverage, and that retained points from unread scopes never are.
2026-11-01 16:39:20 +00:00
pulse-triage[bot]
9cbe12abfe Register PBS owner proofs beside their discovery and read owners
Keep the same executable assertions in the normal Go suite, with named entry points in the existing discovery and read-policy proof routes.

Contract-Neutral: Test entry points only; runtime and public contracts are unchanged.
Change-source: pulse-maintainer
2026-10-30 22:32:00 +00:00
pulse-triage[bot]
11d1620807 Initialize the connection outcome map in namespace poll regressions
The fixture drives the real connection poll and therefore needs its ordinary poll-status map, in addition to backup scheduling and recovery state. Keep the new lifecycle proof independent of fixture setup panics.

Change-source: pulse-maintainer
2026-10-23 22:02:03 +01:00
pulse-triage[bot]
7152d2b7ff Keep failed PBS namespace discovery out of complete backup evidence
Carry namespace discovery errors with the immutable datastore snapshot into background backup polling. Readable root history still updates, but unknown child namespaces cannot delete durable facts or claim complete protection. Cover real HTTP discovery through ingest, replacement state, repeated failures, scoped removal, recovery and legacy root-only support.

Change-source: pulse-maintainer
2026-10-23 21:57:43 +01:00
rcourtman
06b7f5a0b9 Keep fixture alerts from outliving a mock-mode switch
SetMockMode(false) switched the mock package off and then cleared active
alerts, but every path that evaluates mode-dependent data checked the
mode once, up front. A mock alert pass (started from the ticker with go,
so passes overlap), a frontend or ingest refresh evaluating a GetState
snapshot, a backup-age check over fixture recovery rollups, or a
connection check over the mock ledger could already hold fixture data
when the switch happened. Its evaluations then landed after the clear,
in live mode, where nothing evaluates or resolves fixture resources, so
the alerts stayed until the 24-hour stale sweep.

A pass-level lock around checkMockAlerts was tried and reverted: it left
the other paths open and made the mock-mode API wait behind a whole pass
of synchronous event-log writes.

The monitor now owns a mock-mode epoch fence. The mock pass, backup-age
and snapshot checks, connection checks, Docker pruning and the
resource-store refresh take a scope before reading anything
mode-dependent and send each alert-manager call through it. SetMockMode,
now serialized, flips the mode, ends the epoch, waits only for calls
already admitted, and then clears. Unified metrics are evaluated one
resource per call, so the wait covers single calls, not passes.

Registry rebuilds are tracked rather than waited on. A refresh evaluates
the registry it read back only if no rebuild from an ended epoch
overlapped it, and the readers that open or remove alerts from the
inventory use current state until a clean rebuild in the new epoch
replaces the previous mode's registry. The mock supplemental fixture
sources now serve nothing outside mock mode: the router swaps them for
the real pollers only after the switch, refreshing between sources, so
a single switch to live mode used to raise fixture vSphere incidents.

The new tests park a real evaluation at a fixed point (a held lock or a
blocking supplier), switch modes and release it. Against the unfenced
code the mock pass left about 40 fixture alerts, the frontend refresh 5
vSphere incidents and the backup check 137 backup-age alerts in live
mode, and a mock-mode connection observation counted toward a live
connection's confirmation. The drain, republish and pruning tests fail
against a fence without its wait, overlap check or registry tracking.
Switching mock mode with several tenant monitors running remains
uncovered and is noted in the monitoring contract.
2026-10-07 12:03:38 +01:00
pulse-triage[bot]
463482f67d Make PBS recovery history test bucket-safe
The metrics store retains second-resolution samples. Verify a changed observed memory value after recovery, rather than requiring a second row when polls share a bucket.

Change-source: pulse-maintainer
2026-09-29 22:56:34 +01:00
pulse-triage[bot]
5e57a07780 Record PBS node status in service History
Persist measured PBS CPU and memory on the service metrics target when node status succeeds. Keep host-agent history separate and avoid false samples on unavailable status. Cover service reads, denial and recovery.

Change-source: pulse-maintainer
2026-09-29 22:53:25 +01:00
pulse-triage[bot]
eccb64d155 fix(alerts): honour PBS datastore capacity policy
Keep topology capacity bands as resource risk rather than duplicate parent and datastore alerts. The existing live PBS capacity evaluator owns thresholds, aliases and hysteresis; retain datastore state failures and reconcile old duplicates normally.

Reproduce the 97.9% report with real registry projection and exercise threshold changes through synthetic PBS HTTP polling. Release adaptations require the live-poll evaluator, not this filter alone.

Change-source: pulse-maintainer
2026-09-09 20:01:19 +01:00
pulse-triage[bot]
f5eba15cf6 test(pbs): enforce datastore policy through live polling
Cover disabled alerting, storage suppression and canonical datastore overrides before the polled capacity lifecycle. Removing the conversion alias makes the disabled-override regression case fail.

Change-source: pulse-maintainer
2026-09-06 14:02:02 +01:00
pulse-triage[bot]
64575d7b7d test(pbs): preserve capacity incidents across failed datastore listings
Fresh PBS polling now evaluates datastore alerts directly. Protect the missing-list boundary so permission errors, upstream failures, malformed responses and empty listings cannot silently resolve an existing capacity incident during unified sync; retain observed recovery and recurrence checks.

Change-source: pulse-maintainer
2026-09-06 13:24:18 +01:00
pulse-triage[bot]
3b21ed22a4 fix(pbs): evaluate configured datastore alerts on live polls
Connect fresh PBS storage observations to the existing capacity and connectivity evaluator. Exercise HTTP polling through unified sync, absent counter retention, confirmed empty recovery and recurrence with alternate counter names.

Change-source: pulse-maintainer
2026-09-06 12:59:04 +01:00
pulse-triage[bot]
2b78867cae fix(pbs): preserve metric alerts when node status is unavailable
A reachable PBS can deny or fail its node-status endpoint while datastore collection succeeds. The resulting zero values previously resolved active CPU and memory alerts without a healthy measurement. Carry internal availability evidence from polling and skip metric evaluation for those samples, preserving independent connectivity and policy suppression. Add failing-before unit coverage and an HTTP polling lifecycle regression for dispatch and recent recovery history.

Change-source: pulse-maintainer
2026-09-05 16:26:42 +01:00
rcourtman
2ca84cddd7 Prevent connection alerts from bypassing offline policy 2026-08-24 22:45:59 +01:00
rcourtman
70f7ca9f6f fix(pbs): skip superuser-only node lookup for tokens 2026-08-09 12:25:07 +01:00
rcourtman
397cad802c Merge PBS API and agent rows via the PBS-reported node hostname
Connected systems showed a PBS machine twice (API row plus host-agent row)
whenever the PBS connection was configured with an address the agent never
reports, because PBS identity was limited to the configured name and host.
The PBS poll now captures the hostname the node reports about itself
(GET /nodes, the previously unused client GetNodeName) on
models.PBSInstance.NodeName, and /api/connections includes it in the PBS
connection's host aliases, so directPlatformHostAttachment merges the agent
running on that machine into the PBS row the same way PVE composes from
API-reported node identity. Node-name fetch failure stays partial data and
never fails the poll. Reported by Johannes Strasser (rc.5).
2026-08-01 22:12:46 +01:00
courtmanr@gmail.com
101735588c Add Docker host web interface access (#1276) 2026-07-30 09:31:28 +01:00
rcourtman
4815a5c80d Fix PBS connection health authority 2026-07-24 09:45:05 +01:00
rcourtman
d55888fb7f Correct PBS job health evidence boundaries 2026-05-13 17:05:03 +01:00
rcourtman
dd8c3a78ce Add PBS job health evidence ledger 2026-05-13 17:05:03 +01:00
rcourtman
6e9c360301 Propagate PBS datastore health into monitoring 2026-05-13 13:15:10 +01:00
rcourtman
bd7d196c11 Mark failed PBS poll as failure and lock down with regression tests
The PBS poller's version-failure exit at monitor_pbs_pmg.go did not
set pollErr before returning, so even after fixing the defer-arg
capture in bf6261adc the deferred recordTaskResult still saw nil and
recorded the poll as a success. PMG's analogous path already sets
pollErr correctly. Mirror that here so the per-instance pollStatusMap,
the connections aggregator, and the circuit breaker all see PBS auth
and version failures as failures.

Add assertions to the existing PBS and PMG auth-failure tests that
the per-instance pollStatusMap entry has a zero LastSuccess and a
non-zero ConsecutiveFailures. The original tests covered downstream
state but not the recorder, which is why two distinct cases of this
class of bug went unnoticed.
2026-05-08 19:53:03 +01:00
rcourtman
9c3d96cab2 Add unified connections API (list + probe) with Disabled flag
Introduces GET /api/connections and POST /api/connections/probe as the
backend half of the one-ledger / one-editor connection redesign.

- GET /api/connections aggregates PVE/PBS/PMG/VMware/TrueNAS/agent rows
  into a unified Connection shape with derived state (active, paused,
  unauthorized, unreachable, stale, pending) computed from in-memory
  scheduler health plus agent Host.LastSeen. No new persisted state.
- POST /api/connections/probe fingerprints a host across the five
  supported products in parallel (2s dial + 1s read, 3s total, max 5
  concurrent). Admin-gated (RequireAdmin + ScopeSettingsWrite) to block
  unauthenticated SSRF against internal hosts.
- Disabled bool on PVEInstance/PBSInstance/PMGInstance (zero-value =
  enabled, preserves existing nodes.json); pollers skip disabled
  instances at client init, reconnect, and per-node iteration.
- NodeConfigRequest/Response gain Enabled; write path translates
  *bool -> Disabled so omitted field leaves state untouched.
- ConnectionsAPI frontend client (list/probe) typed off the Go shape.

Contracts updated: api-contracts, monitoring, agent-lifecycle,
performance-and-scalability, storage-recovery. Proofs added:
contract_test.go JSON snapshot for Connection and ProbeResponse,
monitoring guardrails for the Disabled-skip behavior, and a vitest
mock-client test for ConnectionsAPI.

Frontend editor / drawer / table rewrite lands in a separate block.
2026-04-19 11:42:53 +01:00
rcourtman
90cce6d51b test(monitoring): fix failing snapshot tests and improve coverage
- Fix TestMonitor_PollGuestSnapshots_Coverage by correctly initializing State ID fields
- Improve PBS client to handle alternative datastore metric fields (total-space, etc.)
- Add comprehensive test coverage for PBS polling, auth failures, and datastore metrics
- Add various coverage tests for monitoring, alerts, and metadata handling
- Refactor Monitor to support better testing of client creation and auth handling
2026-01-04 10:29:40 +00:00