Skip to content

fix(ci): unbreak the kind probe and widen the ECR retention window - #1108

Merged
athvin merged 3 commits into
mainfrom
fix/kind-probe-and-ecr-window
Nov 17, 2026
Merged

athvin merged 3 commits into
mainfrom
fix/kind-probe-and-ecr-window

Conversation

@athvin

@athvin athvin commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #1106
Closes #1101

Three follow-ups from the cost review and the open-PR sweep. Each is small; the
reasoning behind two of them is the part worth reading, because in both cases
the obvious fix is wrong.

1. The kind probe — red seven days, and a security fix caused it

#1075 (7cad4ad) reprojected list_job_tasks through TaskInstanceWire,
which does not carry token_hash, and added a test that the public list must
omit
it. scripts/check_kind.sh still subscripted the field, so phase 1 died
on KeyError: 'token_hash'. The API change landed 11-09; the probe went red
11-10 and stayed red.

The obvious repair is t.get("token_hash") is None. That stops the crash and
asserts nothing — the key can no longer be present, so the condition cannot
fail. Instead this asserts the property the wire projection actually
guarantees, which has a real failure mode (someone re-exposing the field).

Mutation-tested by running the extracted phase-1 block against three shapes:

shape expected result
today's wire shape (field absent) pass exit=0
field re-added as null fail exit=1
field re-added with a real hash fail exit=1

Note the middle row: the old assertion would have passed a re-exposed
null. This is strictly stronger than what it replaces, not a weakening to get
green.

2. The ECR window — the free-looking fix destroys the registry

"Retain the last 30 images" reads as weeks and measured ~1.5 days, which is
what broke a dev namespace pinned to a 33-day-old tag with
ErrImagePull ... not found — a message that reads as a registry fault.

The budget counts manifests, and one build pushes three. Measured on
er-api (48 manifests, 16 tagged):

16  tagged     application/vnd.oci.image.index.v1+json      <- what a tag names
16  UNTAGGED   application/vnd.oci.image.manifest.v1+json   <- the platform image
16  UNTAGGED   .../vnd.docker.attestation.manifest.v1+json  <- buildkit SLSA

So 30 manifests was ten pullable builds, which at the measured ~10
builds/day is the 1.5-day window.

Two-thirds of the budget being untagged looks like free headroom, and an
expire-untagged rule is the natural reach. It would break every image in the
registry
— the 16/16/16 symmetry is not a coincidence, those untagged
manifests are the live children of the tagged indexes, so expiring them deletes
the platform image each tag resolves to. Raising the count is the only safe
lever here, and it stays a count rather than an age because ECR permits one
tagStatus: any rule, so an age rule cannot sit beside this one and any
tag-scoped rule reintroduces the hazard.

900 manifests = ~300 builds = ~30 days at the measured rate, and longer while
the repo is quiet, which is the idle-dev-namespace case. Cost ceiling, using
per-image sizes that double-count shared layers so the real figure is lower:
300 x (107 + 68 + 204) MB ~= 114 GB ~= $11/month. The three repos held 16.8 GB
before this.

3. The applied Aurora moved blocks

#1096 keyed aws_rds_cluster_instance.prod by identifier and carried the
instances across with two moved blocks. That applied — the cluster now has
exactly one member, er-prod-2, the writer — so they are inert. Removed, and
the comment now records that a single instance makes any reboot-requiring
change (a static cluster parameter, say) an outage rather than a failover.

This does not close #1100. Its other half is re-measuring the RDS cost line
to confirm the ~$1.44/day fall was real rather than inferred from the ACU
floor, and that needs ~3 days of billing data after the apply.

Post-merge ledger

Closed by: agent · session f14bf995-5565-41eb-9658-d3746dc3188e on Mac · 2026-11-17T06:20:00Z

  • main is green with this change on it — merge SHA
    2d3a32bef453cd16ea26a5397ae7a2effb8db125, which is current main. On
    that SHA: rust, frontend, infra and devcontainer all
    completed/success. main had not moved since the branch was cut
    (5723b006 both times), so the green was not stale.
  • images — n/a — correctly never ran. images.yml's push paths are
    rust/**, frontend/**, infra/k8s/**, scripts/dev_env.sh,
    scripts/obs_up.sh, scripts/ci/images-detect.sh and the two workflow
    files. This change touches scripts/check_kind.sh and
    infra/terraform/**, none of which is an image input. Verified: no
    images run exists for this SHA.
  • deploy — n/a — deploy.yml is triggered only by
    workflow_run: [images], and images correctly did not run, so no deploy
    fired and none should have. Nothing that goes into a running process
    changed; the Terraform was applied by infra instead (below).
  • the push-only surface — both halves now green, which is the point
    of this change
    :
    kind — dispatch run 44025072671 on the branch, completed/success,
    check_kind: ALL PHASES PASS, including the line that was crashing:
    phase 1 ok: both rows succeeded as real pods. This is the only way to
    prove it, since the probe is if: github.event_name != 'pull_request'.
    drift — run 44028569138, all four legs green (core, dev, prod,
    state-backend). See the note below on why it had been red.
  • the board card — kind probe red since 2026-11-10: KeyError 'token_hash' after the credential-omission fix #1106 and ECR "retain last 30 images" gives a ~1.5-day window and breaks pinned dev deployments #1101 both reached CLOSED through
    GitHub's closing references rather than by hand.
  • follow-ups are open for everything deferred here — numbers: The er-alerts SNS email subscription has never been confirmed — 19 armed alarms reach nobody #1107
    (the unconfirmed SNS subscription, which is the real cause of the drift
    red and needs one click from the owner) and Post-apply cleanup for the prod Aurora reader removal: drop the moved blocks, confirm the saving #1100 (re-measure the RDS
    line; earliest meaningful read 2026-11-20).
  • what was learned is written down — memory
    kind-probe-never-passed updated with the sixth cause and the
    OTLP-noise-at-the-tail trap, plus
    ecr-retain-30-is-a-day-and-a-half corrected: the window is
    30 ÷ 3 manifests-per-build = ten builds, and the expire-untagged "fix"
    would delete the tagged indexes' platform children.

Specific to this change

  • the kind probe is proved green on a real run — dispatch
    44025072671, all six phases, as above. A pull request cannot run it and
    this one did not; the PR's green says nothing about the probe.
  • apply (core) applied the ECR policy, and the live policy reads 900
    on all three repositories — read back rather than inferred from the apply
    conclusion:
    er-api: countNumber=900, er-web: countNumber=900,
    er-pipeline: countNumber=900, each imageCountMoreThan / tagStatus=any.
    The three destroys in the plan were lifecycle-policy replacements, not
    images, which is why ALLOW-DESTROY was correct to pass here.
  • apply (prod) planned 0/0/0 for the moved removal —
    plan (prod) read No changes. Your infrastructure matches the configuration. and apply (prod) succeeded. Deleting an applied moved
    block is a no-op, and anything else would have meant the state did not
    move the way Remove the prod Aurora reader replica (-$43/mo, gives up automatic failover) #1096 believed.
  • the drift (prod) red seen immediately after this merge was
    investigated, not waved through.
    It reported
    REAL DRIFT: aws_rds_cluster.prod [cluster_members] — a stale computed
    attribute left by Remove the prod Aurora reader replica (-$43/mo, gives up automatic failover) #1096's reader removal. It was a race, not a finding:
    that drift run started at 06:02:07 and apply (prod) ran 06:02:13→06:03:00,
    so the refresh-only plan read state mid-apply. Re-dispatching drift
    after the apply returned all four legs green.
  • Post-apply cleanup for the prod Aurora reader removal: drop the moved blocks, confirm the saving #1100 was closed by accident and has been reopened — the commit body
    said "Does not close Post-apply cleanup for the prod Aurora reader removal: drop the moved blocks, confirm the saving #1100" and GitHub's parser matched
    close #1100, ignoring the negation. Reopened with the outstanding
    measurement recorded on it.
Context

drift (core), which was the other half of #1106 as originally filed, is not
fixed here and is not broken
. It was correctly reporting real drift: the
er-alerts SNS email subscription has never been confirmed, so AWS deleted the
pending subscription about three days after the alarms were created.
tf-drift-classify.sh flagged it exactly as designed. That is now #1107,
which needs one click from the owner of the subscribed address — 19 alarms are
armed and reaching nobody — so #1106 was rescoped to the kind probe alone
rather than closed over a problem it does not cover.

Verified locally before pushing: terraform fmt -check -recursive,
credential-free init -backend=false && validate on both envs/core and
envs/prod, bash -n scripts/check_kind.sh, all five embedded python blocks
compile, and scripts-home-check / workflow-shell-check /
tf-static-credentials-check all pass. A full cold make check was not run in
this worktree because the change touches no Rust and no frontend; CI runs it.

#1075 (7cad4ad) reprojected list_job_tasks through TaskInstanceWire, which
does not carry token_hash, and added a test that the public list must omit it.
check_kind.sh still subscripted the field, so phase 1 died on
`KeyError: 'token_hash'` and the probe has been red every day since
2026-11-10 — a sixth cause, and one a security fix introduced.

Asserting `.get(...) is None` would stop the crash and prove nothing, since
the key can no longer be present. This asserts the property the wire
projection guarantees, which has a real failure mode: re-exposure. Mutation-
tested — passes on today's shape, fails both with the field re-added as null
and with a real hash, so it is strictly stronger than the assertion it
replaces.

Closes #1106
"Retain the last 30 images" reads as weeks and measured ~1.5 days, which is
what broke a dev namespace pinned to a 33-day-old tag with
`ErrImagePull ... not found`.

The budget counts MANIFESTS and one build pushes three: measured on er-api,
16 tagged OCI indexes + 16 untagged platform manifests + 16 untagged buildkit
attestations = 48. So 30 manifests was ten pullable builds.

The tempting fix is an expire-untagged rule to reclaim that two-thirds. It
would delete the platform children the tagged indexes resolve to — the 16/16/16
symmetry is not a coincidence — breaking every image in the registry. Raising
the count is the only safe lever, and it stays a count because ECR permits one
`tagStatus: any` rule, so an age rule cannot sit beside this one.

Cost ceiling, from per-image sizes that double-count shared layers:
300 builds x (107 + 68 + 204) MB ~= 114 GB ~= $11/month. The three repos held
16.8 GB before this.

Closes #1101
#1096 keyed aws_rds_cluster_instance.prod by identifier and carried the
instances across with two moved blocks. That applied on 2026-11-17 — the
cluster now has exactly one member, er-prod-2, the writer — so the blocks are
inert. Records in their place that a single instance makes any reboot-requiring
change an outage rather than a failover.

Does not close #1100: its other half is re-measuring the RDS cost line, which
needs ~3 days of billing data after the apply.
@github-actions

Copy link
Copy Markdown
Contributor

terraform plan

c0203ca · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 3 0 3
dev 0 0 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

Warning

This plan DESTROYS resources in: core. Merging applies it unattended.
The apply refuses to run unless the merge commit message carries
ALLOW-DESTROY. Retitling is not enough on a single-commit PR — GitHub
uses the commit message there, not the title. Merge with
gh pr merge <n> --squash --subject '<subject> ALLOW-DESTROY'.

core — 3 to add, 0 to change, 3 to DESTROY
module.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Read complete after 0s [id=2350222434]
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Read complete after 0s [id=2395007408]
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.obs_pod_trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.cur_delivery: Reading...
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.config_bucket: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
data.aws_iam_policy_document.openobserve: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.openobserve: Read complete after 0s [id=2662704728]
data.aws_iam_policy_document.sccache_write: Reading...
data.aws_iam_policy_document.sccache_read: Reading...
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
module.github_oidc.data.aws_iam_policy_document.push: Reading...
module.github_oidc.data.aws_iam_policy_document.push: Read complete after 0s [id=2177873069]
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_drift_trust: Reading...
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.ci_tf_drift_trust: Read complete after 0s [id=3359896184]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 0s [id=us-east-2]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 0s [id=b17b2500-e0b1-7046-405b-23c088cf392b]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_ecr_lifecycle_policy.this["er-api"] must be replaced
-/+ resource "aws_ecr_lifecycle_policy" "this" {
      ~ id          = "er-api" -> (known after apply)
      ~ policy      = jsonencode(
          ~ {
              ~ rules = [
                  ~ {
                      ~ description  = "Retain the last 30 images" -> "Retain the last 900 manifests (~300 builds; 3 manifests per build)"
                      ~ selection    = {
                          ~ countNumber = 30 -> 900
                            # (2 unchanged attributes hidden)
                        }
                        # (2 unchanged attributes hidden)
                    },
                ]
            } # forces replacement
        )
      ~ registry_id = "797781631727" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # aws_ecr_lifecycle_policy.this["er-pipeline"] must be replaced
-/+ resource "aws_ecr_lifecycle_policy" "this" {
      ~ id          = "er-pipeline" -> (known after apply)
      ~ policy      = jsonencode(
          ~ {
              ~ rules = [
                  ~ {
                      ~ description  = "Retain the last 30 images" -> "Retain the last 900 manifests (~300 builds; 3 manifests per build)"
                      ~ selection    = {
                          ~ countNumber = 30 -> 900
                            # (2 unchanged attributes hidden)
                        }
                        # (2 unchanged attributes hidden)
                    },
                ]
            } # forces replacement
        )
      ~ registry_id = "797781631727" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # aws_ecr_lifecycle_policy.this["er-web"] must be replaced
-/+ resource "aws_ecr_lifecycle_policy" "this" {
      ~ id          = "er-web" -> (known after apply)
      ~ policy      = jsonencode(
          ~ {
              ~ rules = [
                  ~ {
                      ~ description  = "Retain the last 30 images" -> "Retain the last 900 manifests (~300 builds; 3 manifests per build)"
                      ~ selection    = {
                          ~ countNumber = 30 -> 900
                            # (2 unchanged attributes hidden)
                        }
                        # (2 unchanged attributes hidden)
                    },
                ]
            } # forces replacement
        )
      ~ registry_id = "797781631727" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

Plan: 3 to add, 0 to change, 3 to destroy.

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

Labels

None yet

Projects

None yet

2 participants