PER-10496 feat: emit machine identity for slow-build diagnostics - #2384
PER-10496 feat: emit machine identity for slow-build diagnostics#2384Shivanshu-07 wants to merge 5 commits into
Conversation
New env.machine getter (hostname-based id with CI node-index suffix, per-provider run URL) sent as build-create attributes plus an X-Percy-Machine-Id header on snapshot/finalize calls so percy-api can track per-machine liveness on parallel builds and name the dead machine when one stops sending. The getter is excluded from env debug logging (those logs are uploaded with build logs) and the header is attached per-call, never in headers(), so it cannot reach off-domain requests. percy-api validates everything server-side; old CLIs degrade gracefully.
@percy/env enforces 100% line and branch coverage; the new machine getter left the buildkite/gitlab cases, the hostname failure path and the optional-var fallbacks uncovered.
@percy/client also enforces 100% branch coverage; the build-attribute spread and machineHeaders() fallbacks (old CLI / no resolvable hostname) were untested.
|
CI is green (30/30). For the record on the two reds seen along the way:
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…d ids on gitlab/jenkins, buildkite job anchor Review follow-ups on the machine-identity getter: - Sanitize the CI shard index like the hostname: the id is an HTTP header value on every snapshot POST, and a stray newline in CIRCLE_NODE_INDEX rejected the upload. - Suffix GitLab CI_NODE_INDEX and Jenkins EXECUTOR_NUMBER so several shards on one host stop sharing a machine id (a dead shard looked alive while a sibling uploaded). - Anchor the Buildkite run url to BUILDKITE_JOB_ID so the link lands on the dead job. - Cap the id at the API's 128 chars; drop an id that sanitizes to dashes alone (non-ASCII hostnames collided); send null instead of the CI/unknown marker. - Tests: one machineAttrs mapping in client.test.js instead of nine pasted copies. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Workspace UI (inherited) Review profile: ASSERTIVE Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Claude Code PR ReviewPR: #2384 • Head: 7f69e07 • Reviewers: fallback inline checklist (built-in code-review: line-by-line scan + reuse finder) SummaryAdds machine identity to Review Table
FindingsFixed in
Open, left as a product call:
Not applied: merging the per-provider machine specs into the existing provider fixture files (churn across five test files for no behaviour change). Verdict: PASS |
Summary
CLI side of Build-processing diagnostics (slow builds) — PER-10496. Pairs with percy-api https://github.com/percy/percy-api/pull/6715, which validates and consumes everything sent here for per-machine liveness on parallel builds (naming the dead CI machine when one stops sending snapshots).
env.machinegetter (@percy/env):{ id, hostname, runUrl }— sanitized-hostname id suffixed with the CI node index where the provider exposes one (CIRCLE_NODE_INDEX,BUILDKITE_PARALLEL_JOB), and the CI run URL for circle/buildkite/github/gitlab. Deliberately excluded from the env getter debug logging (liketoken) — those debug logs are uploaded with build logs, and hostnames should not ride along.@percy/client):machine-id/machine-hostname/machine-ci-run-urlattributes (only when an id exists).X-Percy-Machine-Idheader on snapshot-create and build-finalize calls, attached per-call viamachineHeaders()— never inheaders(), so it cannot leak to off-domain requests (validateDomain).Server-side: percy-api enforces charset/length limits and an https + CI-host allowlist on the URL, and treats all of it as advisory. Old CLI versions degrade gracefully (the feature falls back to non-machine-specific messaging).
Testing
@percy/env: 5 new specs (sanitized id, node-index suffix + run URL on circle, composed GitHub Actions run URL, null run URL fallback, debug-logging exclusion). Suite green (128/128).@percy/client: header specs for snapshot + finalize, machine attributes on build create; existing exact-payload expectations updated. Suite green under node 14 except one pre-existing environmental failure (proxy getProxy should return undefined if no proxy is set) that also fails on a clean checkout on this machine (local proxy present) — unrelated to this change.Post-Deploy Monitoring & Validation
"machine identity ingest skipped"(should stay ≈0); Redis key growthpercy:api:build-machines:*(bounded by active builds, 25h TTL).slow-build-diagnosticsflag ON → build show JSON carries machine facts indiagnosis; kill one shard → machine named in the receiving-state alert.🤖 Generated with Claude Code