feat(api): GET /machines/by-mac/{mac} — single-row MAC lookup#34
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
GET /machinespaginates (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-Installednodes (k8s06–k8s11, machines #26–31 on page 2) on everyprovision_k8srun.Scanning a paginated table to find one row is the wrong primitive anyway.
What
GET /machines/by-mac/{mac}→ thesimpledetail projection (id,hostname,ip_address,mac_address,status,tags) — the same per-row shapeGET /machinesemits — or404when no machine has that MAC.get_machine_by_mac(the same lookupadmin/createupserts with) — no new query.AuthenticatedCallerposture as the machine list).statusfield is byte-identical to the list endpoint (sharedmachine_to_detail_levelprojection), so thestatus == "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
2ef96deonfix/remove-stream-stall-timeoutduring 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