Skip to content

fix(cicd): run the status-bridge ordering guard in the same pod as the POST (#1029) - #1030

Merged
YiannisDermitzakis merged 9 commits into
mainfrom
fix/status-bridge-toctou-1029
Nov 23, 2026
Merged

YiannisDermitzakis merged 9 commits into
mainfrom
fix/status-bridge-toctou-1029

Conversation

@YiannisDermitzakis

Copy link
Copy Markdown
Contributor

Closes #1029

Root cause

stoa-status-bridge's ordering guard was check-then-act across two TaskRuns. current-state read Gitea, and then forward (a separate pod) POSTed to GitHub. So the gap between the read and the write included a whole pod start.

On 2026-11-22 (derio-net/runs-fr PR #52, acceptance-report / pages (push)):

Run State Created Guard read Gitea Posted to GitHub
vwtxc pending 21:41:18 21:41:18–28 (pending was current) 21:42:41
qzshd success 21:41:52 — 21:42:07

The guard's answer was correct at the moment it asked. The POST then happened 74s later. The stale pending posted last, so it won (a commit status is never revisited), and layer-25-delivery-overdue fired. docs/runbooks/frank-gotchas/tekton.md had already named this residual window, but didn't account for the pod start inside it.

Fix

  • New StepAction github-status-report (apps/tekton/tasks/github-status-report.yaml). The POST moved here verbatim from the github-status Task, plus an optional guard-file: true skips the POST, and anything else posts (fail-open).
  • The github-status Task refs the StepAction and passes no guard. I checked programmatically that the script, image, command, securityContext, env, params and computeResources are byte-identical to before, so the 4 CI pipelines' status posts are unchanged.
  • stoa-status-bridge is now one task, forward, with two steps. check writes $(results.superseded.path), and report (the StepAction) reads /tekton/results/superseded. Steps of one TaskRun start back-to-back in one pod, so there is no pod schedule between reading Gitea and writing GitHub.

Failing test first

  • test_stoa_status_bridge.py::test_check_and_post_run_in_one_pod: one task, steps [check, report], and the same result file on both sides.
  • test_github_status_report_guard.py: runs the StepAction's real script with curl stubbed. true → no POST. false, empty, missing file, or no guard → POST. A third test checks that the Task forwards every param and no guard.
  • Before the fix: 12 failed. After: all pass. The existing script tests (token_select, quota_422, ci_delivery_check) now point at the StepAction.

Verification

  • 139 related tests pass, plus 73 Tekton/ArgoCD guard tests, run locally.
  • kubectl apply --dry-run=server --validate=strict on Tekton v1.6.0 accepted the StepAction, the Task, and the Pipeline (an inline taskSpec with a ref: step).
  • Runtime proof can only happen after merge, because the StepAction exists on the cluster only once ArgoCD syncs main.

Post-merge test plan

  • status.operationState.operation.sync.revision on tekton-extras equals the merge SHA, and kubectl -n tekton-pipelines get stepaction github-status-report exists.
  • The next CI pipeline's github-status TaskRun shows Succeeded, and its status lands on GitHub.
  • The next stoa-status-bridge run shows Succeeded with steps check + report, and the status lands on GitHub.
  • A skipped job's pending shows either posted-then-overwritten or pending is stale … not posting in the report step log.
  • ci-delivery-check logs stay free of status delivery mismatch.

The incident status was already repaired via scripts/ci_status_backfill.py (stoa-status-bridge-nc9nv).

🤖 Generated with Claude Code

YiannisDermitzakis and others added 9 commits November 23, 2026 08:28
…e POST (#1029)

The current-state guard and the forward POST were separate tasks, so the
read->POST gap included the forward pod's start. On 2026-11-22
(derio-net/runs-fr PR #52) that took 74s: the guard read Gitea while
pending was genuinely current, the terminal status posted in the gap, and
the stale pending posted last, stranding the GitHub check and firing
layer-25-delivery-overdue.

- New StepAction github-status-report holds the POST, moved verbatim from
  the github-status Task plus an optional guard-file (true = skip,
  anything else posts: fail-open).
- github-status Task now refs it with no guard; its script is
  byte-identical, so CI status posts are unchanged.
- stoa-status-bridge is one task: step `check` writes
  $(results.superseded.path), step `report` reads it. Steps start
  back-to-back in one pod.
- Tests: single-pod shape, guard behaviour against the real script, Task
  delegation; existing script tests retargeted to the StepAction.
- tekton gotcha prose + one-liner updated.

Closes #1029

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ted script tests (#1029)

test_ci_status_always_reported built the Task path from the task name, so
the literal-path sweep missed it. Its loader now executes the StepAction
script a ref: step points at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- plan: repair widen-fr-version-ceiling (11 files)

Migrated automatically at fr CLI entry: the installed fr changed under
artifacts written for an older one (artifact migration framework, spec
2026-08-30 §3.C/§3.D). Only the rewritten artifact paths are in this
commit; unrelated working-tree and staged changes were left alone.

Fr-Commit: migrate
@YiannisDermitzakis
YiannisDermitzakis marked this pull request as ready for review November 23, 2026 08:23
@YiannisDermitzakis
YiannisDermitzakis merged commit 03efdce into main Nov 23, 2026
2 checks passed
@YiannisDermitzakis
YiannisDermitzakis deleted the fix/status-bridge-toctou-1029 branch November 23, 2026 08:23
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.

fix(ci): status-bridge ordering guard is check-then-act — stale pending still posts last

1 participant