Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 2 min read

Cloud Run Jobs Freeze Their Image

Check this first Read the image the job actually runs. gcloud run jobs describe <job> --region=asia-northeast1 \ --format="value(spec.template.spec.template.spec.containers[0].image)" Then check whether your

Check this first

Read the image the job actually runs.

gcloud run jobs describe <job> --region=asia-northeast1 \
  --format="value(spec.template.spec.template.spec.containers[0].image)"

Then check whether your fix is contained in it.

git merge-base --is-ancestor <fix-commit> <image-sha> && echo "contained" || echo "not contained"

If it is not contained, re-running changes nothing. Worse, the job may overwrite data again using the old behaviour.

What is actually happening

The image is pinned in the job definition. When the definition lives in infrastructure-as-code, the tag is declared as a variable, and the job keeps running the old code until that tag is bumped and applied.

local fix β†’ commit β†’ [ wall ] β†’ job execution
                       ↑ image is still the old one

The awkward part is that the run succeeds. Nothing appears in the logs. All you are left with is "I ran it and it did not take effect".

Two ways out

A. Override the environment variable at execution time

If the code reads process.env.X ?? default, you can swap the value without touching the image.

gcloud run jobs execute <job> --region=asia-northeast1 \
  --update-env-vars=KEY=value --wait

No build, no apply, so this is the fast path. But it applies to that execution only β€” the job definition is unchanged, and the old default comes back the next time the flag is omitted.

B. Update the image (the real fix)

Build, bump the tag, apply. The exact commands depend on your setup, but you cannot skip the tag bump.

Preventing a repeat

After this incident we put the sha check at the very top of the runbook. The root cause was that running the job without checking was possible at all, so changing the order of the steps is what actually helps.

We also wrote down, in the runbook, that the environment-variable override is a stopgap. Because it is fast, it is easy to walk away believing the problem is fixed.

Originally published at tech.rebounder.jp.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.