Fix template replacement producing invalid image reference with digests#3440
Open
honnix wants to merge 1 commit into
Open
Fix template replacement producing invalid image reference with digests#3440honnix wants to merge 1 commit into
honnix wants to merge 1 commit into
Conversation
3cd3d93 to
c82da4c
Compare
When an image with a digest is used (e.g. image:tag@sha256:...), the
template replacement for {{.image.<name>.version}} hardcodes : as the
separator. Since version returns the digest, this produces
image:tag:sha256:... (invalid) instead of image:tag@sha256:... (valid).
Fix by detecting when version is a digest (contains :) and replacing
the preceding : separator with @ in the output.
Fixes flyteorg/flyte#7531
Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
c82da4c to
6997496
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking Issue
Closes flyteorg/flyte#7531
Why are the changes needed?
When an image reference with a digest is passed to
pyflyte register --image(e.g.gcr.io/project/image:tag@sha256:digest), the registered task spec contains an invalid image reference with:instead of@before the digest.The root cause is in
get_registerable_container_image(): when replacing{{.image.<name>.version}}in a template, the version value is substituted directly but the separator before the placeholder is always:(hardcoded in the template). Whenversionis a digest (e.g.sha256:...), the separator should be@.Example:
{{.image.default.fqn}}:{{.image.default.version}}gcr.io/project/image:tag@sha256:abc123gcr.io/project/image:tag:sha256:abc123(invalid)gcr.io/project/image:tag@sha256:abc123(valid)This also affects digest-only references (no tag):
gcr.io/project/image@sha256:abc123gcr.io/project/image:sha256:abc123(invalid)gcr.io/project/image@sha256:abc123(valid)What changes were proposed in this pull request?
In
get_registerable_container_image(), when the resolvedversionis a digest (contains:), replace the preceding:separator with@in the output. Tags never contain:, so the check is unambiguous.How was this patch tested?
Added test cases for both scenarios to
test_container_image_conversion:fqnwithout tag) with:template separatorfqncontains baked-in tag) with:template separator — the real-world case from_parse_image_identifier("repo:tag@sha256:...")Existing tests continue to pass.