Skip to content

PR-env deploys: stop phantom image-tag pins#33

Merged
lucas-koontz merged 2 commits into
mainfrom
lucas/eng-877-pr-env-deploys-stop-phantom-image-tag-pins-head-sha-tags-ecr
Jul 20, 2026
Merged

PR-env deploys: stop phantom image-tag pins#33
lucas-koontz merged 2 commits into
mainfrom
lucas/eng-877-pr-env-deploys-stop-phantom-image-tag-pins-head-sha-tags-ecr

Conversation

@lucas-koontz

@lucas-koontz lucas-koontz commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Stops PR-env deploys from pinning image tags that were never built, and makes the
two silent failure modes from the M3 cutover week loud. Fixes the class of
incident where pr-auth-168 / pr-mindshub-frontend-1368 sat in
ImagePullBackOff for 25h on a phantom tag.

Why

Images are tagged development-<merge SHA>, but GitHub regenerates a PR's
synthetic merge commit (new hash, identical content) whenever base or head
moves — we observed two twins born one second apart. argocd-pr-env-deploy
resolves linked PRs' merge_commit_sha via the API at deploy time, so a
cross-PR pin can name a twin no build pushed. Separately, Deploys: lines in
URL form were silently ignored, quietly running envs on defaults.

Changes

build-push-ecr — on pull_request events, additionally tags
<env>-head-<pr head sha>. Head SHAs are immutable, so cross-PR resolution
becomes race-free. Existing tags, outputs, and non-PR builds are unchanged.

argocd-pr-env-deploy

  • Linked-PR pins prefer development-head-<head sha>, fall back to the
    merge-SHA tag for images built before dual-tagging, and fail loudly
    (naming both candidate tags and the re-run fix) when neither exists —
    replacing the silent phantom pin.
  • Every pin (own repo included) is existence-checked via
    aws ecr describe-images. Checks fail-open with a single warning on infra
    errors (missing CLI, auth, throttle) so a degraded runner can't block a
    deploy that would have worked; ImageNotFound is authoritative.
  • Deploys:-looking lines that don't parse (Deploys: <PR URL>, lowercase)
    now emit ::warning:: naming the accepted forms.
  • A failed PR-body fetch now errors with a diagnosable message instead of a
    mute set -e death.

Notes

  • Roll out together: the head-tag preference is harmless-but-inert until
    linked repos rebuild once with the new build action (fallback covers the gap).
  • The deploy side looks for development-head-* specifically; PR builds for
    other build-for-environment values get a head tag deploy doesn't use
    (degrades to today's merge-tag behavior, now with a loud failure when stale).
  • Missing/unmergeable linked PRs remain warn-and-skip; only missing images
    hard-fail.

Verification

Both scripts extracted and executed in a containerized harness (bash 5.2,
stubbed gh_api/aws/argocd): 36/36 assertions across 8 scenarios — head-tag
hit, merge fallback, neither-exists hard-fail (proving the exit 1 propagates
from the main shell, argocd never invoked), #staging passthrough, fail-open
warns exactly once with one AWS call, self-link skip, own-tag-missing message,
URL-form lint. Buildx argv checked: PR events gain exactly two args
(-t, the head tag); push events gain zero (no empty-string arg). shellcheck:
zero findings on the deploy script; only pre-existing style findings on the
build script. YAML parse + bash -n green.

Fixes ENG-877

Improve the logic for selecting image tags by adding an existence check for ECR tags when the ECR_CHECKS flag is enabled. This change aims to prevent phantom image tags that were previously pinned and aligns with pre-hardening behavior under infrastructure errors. Addresses ENG-877.
@lucas-koontz
lucas-koontz merged commit d2ba48a into main Jul 20, 2026
2 checks passed
@lucas-koontz
lucas-koontz deleted the lucas/eng-877-pr-env-deploys-stop-phantom-image-tag-pins-head-sha-tags-ecr branch July 20, 2026 18:54
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.

2 participants