A Stale Branch Deploy Silently Reverted Features
※本記事にはアフィリエイトリンクを含む場合があります。内容は広告の有無に影響されません。
結論
A Cloud Run deploy is only an image tag swap and never looks at branch history, so rebuilding from a branch that diverged long ago removes features already merged to main with no revert commit.
The short version
A Cloud Run deploy is nothing more than rewriting the image tag written in terraform’s locals to a new value and applying; it never looks at branch history. Point the tag at an image built from a branch whose merge base is old, and features merged to main since then disappear from production without a single git revert commit.
What it looks like
Two bug reports of quite different character came in from production at the same time.
- One of the live screen templates, displaying fine moments earlier, stopped displaying
- Changing a template’s settings in the editor has no effect even after saving
They looked like bugs in two unrelated features. One on the delivery side, one on the editing side, in different parts of the code. But they coincided with a bump of the production image tag just beforehand.
# before the bump
web_image_tag = "e95d5ff" # public signage /signage shown on tablet/PC (≥900px) as a fixed-scale reduction
# of the real monitor (16:9, 1920×1080)…
# after the bump (this bump produced the symptoms)
web_image_tag = "9f73a56" # do not apply signage fit-stage on real devices (Android WebView/TV)…
The bump itself looked like exactly the intended change: “do not apply the scaled display on real devices”. The plan shows no destroy. The apply succeeds. The tag string changing was itself correct, and two features disappeared anyway.
Why
The image web_image_tag pointed to was built from a working branch, feat/signage-fit-to-monitor. That branch had diverged from main well before the commit production had been pointing at.
The problem was that after that divergence, two other features had been merged to main.
- A change adding one of the live screen templates
- Three changes fixing template application in the editor
The working branch does not contain those commits. Swapping the tag to an image built from it means bringing a state that is in the past relative to main’s tip straight into production.
image = "${module.artifact_registry.image_repo_url}/web:${local.web_image_tag}"
All the Cloud Run web service looks at on startup is the string this one line assembles. Which commits are inside the image local.web_image_tag points at is none of terraform’s business. Because the tag is being swapped as a string, “a newer tag” and “newer features” are not the same thing.
From git’s side, this operation does not look like a revert either. A revert leaves a new commit in the history; a tag swap never touches commit history at all. Looking at main’s history, the commits for the vanished features are still right there. What disappeared from production did so because the tag pointed at an image that did not include them — the code was not deleted or undone. That shape, “nothing happened in the history and only what is running changed”, is what made the two bugs look unrelated.
Fixing it
Correct recovery meant treating the tag production had deliberately pointed at before the bump as the base, and cherry-picking onto it only the two commits genuinely meant to be added.
web_image_tag = "f3fe951" # incident recovery: bumping prod from a stale branch
# (feat/signage-fit-to-monitor) had silently rolled back pattern4 and
# the editor's pattern resolution. f3fe951 = a12b7ef (contains the
# previous web:a12b7ef) with signage-fit and the real-device fit-stage
# exclusion cherry-picked. No schema change, no secret added or removed
Rebuilding from the latest main is an option, but that carries every other change merged into main into production at once, leaving room for unintended changes. Pinning the base to the previous intended tag, which contains the vanished features, and adding only the delta narrowed the change to the two commits for “do not apply the scaled display on real devices”.
Why it wasn’t noticed
CI verifies the contents of the branch it is told to build; how far behind main that branch is is not among the things it verifies. terraform’s plan shows the image tag string changing, but not which point of main the new tag’s image includes up to. A branch being stale was not something review was conscious of as a review item.
The result is that this kind of rollback is invisible to everyone until symptoms appear. The tag swap passes as a normal apply, and the vanished features’ commits remain in main’s history, so no trace of “what happened” is left on either the infrastructure side or the code history. The only clue was a report from a user who actually touched it: “it’s gone”.
Around Cloud Run image tags, Cloud Run Jobs Freeze Their Image deals with another form of “looking at a tag without really looking at it”. That one is about the same tag being re-pushed and never taking effect; this one is about changing the tag itself and going back to an unintended past.
よくある質問
Q1How did features disappear with no git revert commit?
A deploy just rewrites the image tag in terraform's locals and applies; it never consults git history. Point the tag at an image built from an old branch and features not in that image vanish from production while staying in the code. A tag swap never touches commit history.
Q2How did two unrelated-looking bugs turn out to share a cause?
The reports read as separate features: "one of the live screen templates stopped displaying" and "changing a template in the editor has no effect". Both were changes merged to main after the branch diverged, and neither was in the stale branch's image. One tag swap rolled both back at once.
Q3Was rebuilding from the latest main the right recovery?
It would fix it, but it also drags in whatever else main gained since the intended tag. The actual recovery treated the previously intended tag as the correct base and cherry-picked onto it only the two commits genuinely meant to be added, leaving no room for unintended changes.
Q4Could CI or code review have caught this?
No. CI verifies the contents of the branch it is told to build, not how far behind main that branch is. terraform apply shows the tag string changing in the plan diff, but not which point of main the tag's contents correspond to. A branch being stale was not even a review item.
確認した環境
- Terraform 1.9 / google provider 6.x
- Occurred in production on 2026-06-22 (bump from the stale branch at 12:31, recovery at 13:36)
この記事の根拠
- Terraformファイル 187〜189行目コミット 39cd858
- Terraformファイル 187〜189行目コミット 85d8a61
- Terraformファイル 471〜479行目コミット 85d8a61
本文の主張は、上の記録に書かれていることだけです。運用しているリポジトリは非公開のため リンクは張れませんが、どのファイルの何行目を、どのコミット時点で見て書いたかは 記事ごとに残しています。推測で書いた箇所はありません。