Skip to content

feat(api): GET /machines/by-mac/{mac} — single-row MAC lookup#34

Merged
Zorlin merged 1 commit into
mainfrom
feat/machine-by-mac-lookup
Jun 21, 2026
Merged

feat(api): GET /machines/by-mac/{mac} — single-row MAC lookup#34
Zorlin merged 1 commit into
mainfrom
feat/machine-by-mac-lookup

Conversation

@Zorlin

@Zorlin Zorlin commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Why

GET /machines paginates (per_page: 25). Automation (Jetpack's converge) used to scan that list to find a machine by MAC, so any machine past page 1 was invisible — looked "unregistered" — and got re-imaged on every converge run. In the london lab this wiped six fully-Installed nodes (k8s06k8s11, machines #26–31 on page 2) on every provision_k8s run.

Scanning a paginated table to find one row is the wrong primitive anyway.

What

GET /machines/by-mac/{mac} → the simple detail projection (id, hostname, ip_address, mac_address, status, tags) — the same per-row shape GET /machines emits — or 404 when no machine has that MAC.

  • Reuses the store's existing get_machine_by_mac (the same lookup admin/create upserts with) — no new query.
  • Authenticated read (same AuthenticatedCaller posture as the machine list).
  • The status field is byte-identical to the list endpoint (shared machine_to_detail_level projection), so the status == "Installed" contract consumers depend on is unchanged.

Coverage

The handler is a thin wrapper over the already-tested store method and the shared serialization path. The consumer contract (404 → None, single call — no list scan) is covered exhaustively by jetpack's dragonfly client tests (riffcc/jetpack) — including a regression test pinning that the lookup never lists machines.

Note

This same endpoint also landed (squashed) into 2ef96de on fix/remove-stream-stall-timeout during concurrent editing; this PR extracts it as a standalone, reviewable change. The two are byte-identical, so whichever merges first, the other merges cleanly.

🤖 Generated with Claude Code

Look up one machine by MAC in a single call, returning the `simple`
detail projection (id, hostname, ip_address, mac_address, status, tags)
or 404. Reuses the store's existing get_machine_by_mac (the same lookup
admin/create upserts with).

This is the primitive automation wants instead of scanning GET /machines,
which paginates (per_page 25): any machine past page 1 looks absent, so
Jetpack's converge re-imaged fully-Installed nodes on every run (london
k8s06-11 sat on page 2). With a dedicated endpoint there is no page-2
blind spot.

Consumer-side coverage (404 -> None, no list scan) lives in jetpack's
dragonfly client tests (riffcc/jetpack).

Co-Authored-By: Claude <noreply@anthropic.com>
@Zorlin Zorlin merged commit 44b440c into main Jun 21, 2026
4 checks passed
@Zorlin Zorlin deleted the feat/machine-by-mac-lookup branch June 22, 2026 07:58
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.

1 participant