Skip to content

Commit b84dbee

Browse files
authored
Fixed Docker <unknown> image_id returned from parser using recent BuildKit on Windows (#21000)
The regex we used seems to be outdated, as `writing image sha256:...` now has a trailing duration before `done`. Using the same fix as #20693 by removing the `done` from the regex.
1 parent ac215a6 commit b84dbee

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

docs/notes/2.23.x.md

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Nodejs processes configured with `extra_env_vars`, e.g.
5151
now supports extending the `PATH` variable of such processes. Passing `extra_env_vars=["PATH=/usr/bin"]` was previously
5252
silently ignored.
5353

54+
#### Docker
55+
56+
Fixed a bug where the internal Docker BuildKit parser would return `<unknown> image_id` if the BuildKit output used step durations.
5457

5558
### Plugin API changes
5659

src/python/pants/backend/docker/goals/package_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def parse_image_id_from_docker_build_output(docker: DockerBinary, *outputs: byte
523523
"|".join(
524524
(
525525
# BuildKit output.
526-
r"(writing image (?P<digest>sha256:\S+) done)",
526+
r"(writing image (?P<digest>sha256:\S+))",
527527
# BuildKit with containerd-snapshotter output.
528528
r"(exporting manifest list (?P<manifest_list>sha256:\S+))",
529529
# Docker output.

src/python/pants/backend/docker/goals/package_image_test.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ def test_get_context_root(
16251625
"""
16261626
),
16271627
),
1628-
# Buildkit
1628+
# Buildkit without step duration
16291629
(
16301630
DockerBinary("/bin/docker", "1234", is_podman=False),
16311631
"sha256:7805a7da5f45a70bb9e47e8de09b1f5acd8f479dda06fb144c5590b9d2b86dd7",
@@ -1648,6 +1648,25 @@ def test_get_context_root(
16481648
),
16491649
"",
16501650
),
1651+
# Buildkit with step duration
1652+
(
1653+
DockerBinary("/bin/docker", "1234", is_podman=False),
1654+
"sha256:7805a7da5f45a70bb9e47e8de09b1f5acd8f479dda06fb144c5590b9d2b86dd7",
1655+
dedent(
1656+
"""\
1657+
#5 [2/2] RUN sleep 1
1658+
#5 DONE 1.1s
1659+
1660+
#6 exporting to image
1661+
#6 exporting layers
1662+
#6 exporting layers 0.7s done
1663+
#6 writing image sha256:7805a7da5f45a70bb9e47e8de09b1f5acd8f479dda06fb144c5590b9d2b86dd7 0.0s done
1664+
#6 naming to docker.io/library/my-docker-image:latest 0.1s done
1665+
#6 DONE 1.1s
1666+
"""
1667+
),
1668+
"",
1669+
),
16511670
# Buildkit with containerd-snapshotter 0.12.1
16521671
(
16531672
DockerBinary("/bin/docker", "1234", is_podman=False),

0 commit comments

Comments
 (0)