Fix awsx:ecr:Image refresh crash after 2.19 upgrade - #1943
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. Maintainer note: consult the runbook for dealing with any breaking changes. |
There was a problem hiding this comment.
Reviewed for bugs and CLAUDE.md compliance. No actionable issues found.
The core fix is correct: the opts.urn guard is an established Pulumi component rehydration pattern, registerOutputs is correctly placed on the non-rehydration path so imageUri is persisted for future refreshes, and the three-tier URI fallback (digest → ref → canonicalImageName) is explicitly documented and intentionally scoped in the PR description. No generated files were modified. Tests cover the crash scenario.
Reviewed by Internal Trusted PR Reviewer
To install this agentic workflow, run
gh aw add pulumi-labs/gh-aw-internal/.github/workflows/gh-aw-pr-review.md@9a981e07d7134a447fac35073f0857f8512f16c4
| const repository = new awsx.ecr.Repository("repository", { forceDelete: true }); | ||
|
|
||
| export const repositoryName = repository.repository.name; | ||
| export const image = new awsx.ecr.Image("image", { |
There was a problem hiding this comment.
@corymhall Could this Pulumi program be made into a YAML program or since the component code is in TS it would be problematic?
pose
left a comment
There was a problem hiding this comment.
Thanks for making the test a YAML test @corymhall
|
This PR has been shipped in release v3.6.0. |
Summary
awsx.ecr.Imagerefresh crash when upgrading stacks fromawsx2.19.0imageUrion the component and avoid rebuilding child resources during component rehydration2.19.0 -> currentwith bothrefresh --run-programandup --refresh --run-programMotivation
This PR fixes the scenario reported in #1926.
The issue only shows up on an upgrade path. Fresh
awsx3.x stacks do not reproduce it.The relevant sequence is:
awsx2.19.0.awsx.ecr.Imagecreates adocker:index/image:Imagechild resource.repoDigest, and the component returns a digest-form image URI like:repo@sha256:...awsx.pulumi refresh --run-program.At that point, the new implementation expects the
docker-build:index:Imageworld (digest/ref), but the old stack still contains the legacydocker:index/image:Imagechild.What Was Happening
There are really two separate issues here:
1. Refresh crash on upgrade from 2.19.0
Current
awsx.ecr.Imagederives its output fromdocker-build.Image.ref.On the
2.19.0 -> currentupgrade path duringrefresh --run-program, the child resource has not yet been migrated todocker-build:index:Image, so there is no usablereffrom the new child shape.That led to:
image.refbeingundefinedremoveTagFromRef(image.ref)throwing2. Missing persisted component output
Older
awsx.ecr.Imagedid not callregisterOutputs, so the component’s ownimageUrioutput was not persisted in checkpoint state.That means that on upgrade, the engine cannot rehydrate a previously stored
imageUrifor the component itself and instead has to recompute it from current program behavior.Important Behavior We Verified
Fresh current-version stacks are fine
A fresh stack using current
awsxdoes not reproduce this issue.2.20.0 -> currentis also fineawsx2.20.0 had already switched todocker-build:index:Image, so those stacks already havedigest/refstate and refresh behaves normally.The problematic path is specifically
2.19.0 -> currentThat is the version boundary where the child resource implementation changed from:
docker:index/image:Imageto:
docker-build:index:Imagerefresh --run-programandup --refresh --run-programbehave differentlyFor stacks originating on
2.19.0:refresh --run-programdoes not complete the child-resource migrationup --refresh --run-programdoes replace the old child with the newdocker-build:index:ImageSo the crash happens on refresh, but a full update is able to converge the stack.
Root Cause
The root cause is the combination of:
docker.Imagetodocker-build.Image2.19.0state containingrepoDigestrather thandigest/refawsx.ecr.Imageassumingrefexists in the new worldimageUriFix
This PR takes the narrow, safe fix:
opts.urn), do not reconstruct child resources.registerOutputs({ imageUri })so the component output is persisted going forward.imageUrifromdocker-build.Image, prefer:digestrefThis is enough to eliminate the refresh crash and make the stack converge correctly on the subsequent update path.
Behavioral Note
This PR is intentionally scoped to removing the refresh error.
For stacks that originated on
awsx2.19.0, arefresh --run-programcan still temporarily rewrite the component output from digest form to tag form until a later:pulumi up --refresh --run-programcompletes the child-resource migration to
docker-build:index:Image.That behavior already self-heals once the update runs; this PR ensures refresh no longer crashes on the way there.
Testing
Unit
yarn --cwd awsx test ecr/image.test.ts --runInBandyarn --cwd awsx tsc --noEmitRepro coverage
Added a targeted upgrade repro that exercises:
awsx2.19.0pulumi refresh --run-programpulumi up --refresh --run-programfixes #1926