Skip to content

Commit

Permalink
docker: fix missing image_id when using containerd-snapshotter (#20533)
Browse files Browse the repository at this point in the history
fixes: #20520
  • Loading branch information
chris-smith-zocdoc authored Feb 12, 2024
1 parent ce66d9b commit e37ecb7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/python/pants/backend/docker/goals/package_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ def parse_image_id_from_docker_build_output(docker: DockerBinary, *outputs: byte
(
# BuildKit output.
r"(writing image (?P<digest>sha256:\S+) done)",
# BuildKit with containerd-snapshotter output.
r"(exporting manifest list (?P<manifest_list>sha256:\S+) done)",
# Docker output.
r"(Successfully built (?P<short_id>\S+))",
),
Expand All @@ -539,7 +541,11 @@ def parse_image_id_from_docker_build_output(docker: DockerBinary, *outputs: byte
None,
)
if image_id_match:
image_id = image_id_match.group("digest") or image_id_match.group("short_id")
image_id = (
image_id_match.group("digest")
or image_id_match.group("short_id")
or image_id_match.group("manifest_list")
)
return image_id

return "<unknown>"
Expand Down
41 changes: 41 additions & 0 deletions src/python/pants/backend/docker/goals/package_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,47 @@ def test_get_context_root(
),
"",
),
# Buildkit with containerd-snapshotter
(
DockerBinary("/bin/docker", "1234", is_podman=False),
"sha256:b2b51838586286a9e544ddb31b3dbf7f6a99654d275b6e56b5f69f90138b4c0e",
dedent(
"""\
#9 exporting to image
#9 exporting layers done
#9 exporting manifest sha256:7802087e8e0801f6451d862a00a6ce8af3e4829b09bc890dea0dd2659c11b25a done
#9 exporting config sha256:c83bed954709ba0c546d66d8f29afaac87c597f01b03fec158f3b21977c3e143 done
#9 exporting attestation manifest sha256:399891f9628cfafaba9e034599bdd55675ac0a3bad38151ed1ebf03993669545 done
#9 exporting manifest list sha256:b2b51838586286a9e544ddb31b3dbf7f6a99654d275b6e56b5f69f90138b4c0e done
#9 naming to myhost.com/my_app:latest done
#9 unpacking to myhost.com/my_app:latest done
#9 DONE 0.0s
"""
),
"",
),
# Buildkit with containerd-snapshotter and cross platform
(
DockerBinary("/bin/docker", "1234", is_podman=False),
"sha256:3c72de0e05bb75247e68e124e6500700f6e0597425db2ee9f08fd59ef28cea0f",
dedent(
"""\
#12 exporting to image
#12 exporting layers done
#12 exporting manifest sha256:452598369b55c27d752c45736cf26c0339612077f17df31fb0cdd79c5145d081 done
#12 exporting config sha256:6fbcebfde0ec24b487045516c3b5ffd3f0633e756a6d5808c2e5ad75809e0ca6 done
#12 exporting attestation manifest sha256:32fcf615e85bc9c2f606f863e8db3ca16dd77613a1e175e5972f39267e106dfb done
#12 exporting manifest sha256:bcb911a3efbec48e3c58c2acfd38fe92321eed731c53253f0b5c883918420187 done
#12 exporting config sha256:86e7fd0c4fa2356430d4ca188ed9e86497b8d03996ccba426d92c7e145e69990 done
#12 exporting attestation manifest sha256:66f9e7af29dd04e6264b8e113571f7b653f1681ba124a386530145fb39ff0102 done
#12 exporting manifest list sha256:3c72de0e05bb75247e68e124e6500700f6e0597425db2ee9f08fd59ef28cea0f done
#12 naming to myhost.com/my_app:latest done
#12 unpacking to myhost.com/my_app:latest done
#12 DONE 0.0s
"""
),
"",
),
# Podman
(
DockerBinary("/bin/podman", "abcd", is_podman=True),
Expand Down

0 comments on commit e37ecb7

Please sign in to comment.