Skip to content

feat(jobs): expose lease health in metrics and the admin console (#1230) - #1249

Open
HugoXK wants to merge 2 commits into
mainfrom
feat/1230-lease-metrics
Open

HugoXK wants to merge 2 commits into
mainfrom
feat/1230-lease-metrics

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Written-by: HugoXK

Fixes #1230

What changed

  • fledge_job_lease_age_seconds — the age of the oldest live lease, published on every scheduler tick and removed when no lease is live, so an empty panel means "none", not a stale reading.
  • fledge_job_lease_renew_failures_total{kind} — a live job's heartbeat renewal was refused because the lease moved; a terminal row releasing its lease is the normal end and is not counted.
  • The existing fledge_lease_expired_total{kind} is the reaped count. The issue named a second fledge_job_leases_reaped_total; adding it would count the same reap twice, so the alert and the card read the existing counter and the docs say which name means what.
  • Store.oldestLiveLease() and Store.lastReapedLease() read the durable jobs/job_attempts rows rather than an in-process counter. The reaped row is the terminal reaped attempt the reaper writes in the same transaction that finalises the job.
  • The /admin/metrics Automation health card now shows the oldest live lease (job, kind, repository, held-for, expires-in) and the newest reaped attempt (job, kind, repository, age). The card says the counters restart with the process while the two lease rows come from the database.
  • FledgeLeaseReaped pages on increase(fledge_lease_expired_total[15m]) > 0. No for delay: one reaped lease is enough to look.
  • docs/architecture.md (Lease health) and docs/observability.md (series, card, alert) record the semantics. One changelog.d/1230.added.md fragment.
  • Tests: test/leaseHealth.test.ts covers the two store reads, the card summary and the gauge presence/absence; test/automationHealth.test.ts covers the alert reading a series the code records; the existing card and page fixtures carry the new fields.

Ran:

  • npx tsx --test test/leaseHealth.test.ts test/automationHealth.test.ts test/sloDefinitions.test.ts test/alertBuckets.test.ts — 19 pass, 0 fail
  • npm run lint — 11 baseline warnings, unchanged
  • npm run typecheck — pass
  • npm run build — pass
  • npm test — 3322 pass / 9 fail. The same 9 fail on the untouched v0.5.0 tree in a second worktree: deployAutomation (5), gateBaseTree (1), nginxCheck (2), securityHeaders (1). They are macOS host/tool failures, not this diff.

Not run:

  • Docker image and the Playwright visual matrix; this change has no route, page structure or asset change.
  • A green npm run check on this macOS host is blocked by the same 9 pre-existing failures; lint, typecheck and build pass before them.

Risks

  • The gauge is one series for the oldest lease, not one per job. That keeps cardinality bounded; the admin card names the job behind the reading.
  • fledge_lease_expired_total is now described as the reaped count. That is the event the counter has always recorded; no value changes.
  • T3 (deploy/, src/db.ts, src/jobs/, docs/architecture.md). The tip needs a PASS from HugoXK-bot; the author of the tip may not PASS it. I have not posted one.

Docs updated: docs/architecture.md — Lease health (#1230); docs/observability.md — Core series, Automation health card and the FledgeLeaseReaped alert.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST_CHANGES at 4ea3de4

  • Missing screenshots: this is a console UI change — src/views/pages.ts:4850-4851 adds two rows to the /admin/metrics Automation health card and :4854-4855 rewrites its footer — and the PR carries no before/after pair (nothing in the body, no comment, and no evidence/1230 or evidence/1249 branch).
  • Attach a same-view, same-width before/after pair as raw links (for example an evidence/1230 branch, as evidence/659 did for #1201 and evidence/1198-clock-fail-banner for #1202), both languages and both viewports; the tip itself does not need to move.
  • The rest of the diff read consistent and CI at this sha is green except review-gate: the reaper writes the terminal reaped attempt in the same transaction (src/jobs/service.ts:1860), oldestLiveLease/lastReapedLease read those durable rows (src/db.ts:7683-7712), and FledgeLeaseReaped reads the counter the tick increments (deploy/prometheus/fledge-alerts.yml:80-91).

Written-by: HugoXK-bot

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(jobs): expose lease age and reaped-lease metrics with an SLO alert

2 participants