Skip to content

Commit 01e7d8f

Browse files
committed
fix(agents): use pushed Podman manifest digest
Signed-off-by: John Myers <[email protected]>
1 parent f408100 commit 01e7d8f

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎scripts/agents/image.sh‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,23 @@ deliver_agent_image() {
8181
;;
8282
registry)
8383
log "Publishing '$image_tag'."
84-
ce push "$image_tag" || fail "image push failed"
8584
local repository="${image_tag%:*}"
85+
if [[ "$CONTAINER_ENGINE" == podman ]]; then
86+
# Podman may convert the manifest on push. RepoDigests describes
87+
# the local image, not necessarily the manifest in the registry.
88+
local digest_dir digest
89+
digest_dir="$(mktemp -d)" || fail "cannot create push digest directory"
90+
if ! ce push --digestfile "$digest_dir/digest" "$image_tag"; then
91+
rm -rf "$digest_dir"
92+
fail "image push failed"
93+
fi
94+
digest="$(cat "$digest_dir/digest" 2>/dev/null)" || digest=""
95+
rm -rf "$digest_dir"
96+
[[ "$digest" =~ ^sha256:[a-f0-9]{64}$ ]] || fail "cannot resolve published image digest; refusing mutable-tag launch"
97+
SANDBOX_FROM="$repository@$digest"
98+
return
99+
fi
100+
ce push "$image_tag" || fail "image push failed"
86101
SANDBOX_FROM="$(ce image inspect "$image_tag" --format '{{json .RepoDigests}}' | ruby -rjson -e '
87102
digests = JSON.parse(STDIN.read) || []
88103
normalize = lambda do |repository|

‎scripts/agents/image_test.sh‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ set -eu
3535
echo "docker $*" >> "$CALLS"
3636
case "$1" in
3737
--version) echo 'Docker test stub' ;;
38-
push) exit "${TEST_PUSH_STATUS:-0}" ;;
38+
push)
39+
if [[ "${2:-}" == --digestfile && "${TEST_SKIP_DIGEST:-0}" != 1 ]]; then
40+
printf '%s\n' "${TEST_PUSH_DIGEST:-sha256:$TEST_DIGEST}" > "$3"
41+
fi
42+
exit "${TEST_PUSH_STATUS:-0}"
43+
;;
3944
image) printf '["%s@sha256:%s"]\n' "${TEST_INSPECT_REPOSITORY:-registry.test/team/gator}" "$TEST_DIGEST" ;;
4045
esac
4146
SH
@@ -85,6 +90,23 @@ TEST_PUBLISH=docker.io/team/gator:tooling TEST_INSPECT_REPOSITORY=team/gator \
8590
grep -Fxq "docker.io/team/gator@sha256:$TEST_DIGEST" "$tmp/out"
8691
echo 'ok - Docker Hub digest normalization preserves the explicit registry'
8792

93+
: > "$CALLS"
94+
pushed_digest="sha256:$(printf 'b%.0s' {1..64})"
95+
TEST_ENGINE=podman TEST_PUBLISH=registry.test/team/gator:tooling \
96+
TEST_PUSH_DIGEST="$pushed_digest" run_transport > "$tmp/out"
97+
grep -Fxq "registry.test/team/gator@$pushed_digest" "$tmp/out"
98+
grep -Fq 'push --digestfile ' "$CALLS"
99+
if grep -Fq 'image inspect' "$CALLS"; then
100+
fail 'Podman registry delivery used the local image digest'
101+
fi
102+
TEST_ENGINE=podman TEST_PUBLISH=registry.test/team/gator:tooling \
103+
TEST_PUSH_DIGEST=malformed expect_failure run_transport
104+
TEST_ENGINE=podman TEST_PUBLISH=registry.test/team/gator:tooling \
105+
TEST_SKIP_DIGEST=1 expect_failure run_transport
106+
TEST_ENGINE=podman TEST_PUBLISH=registry.test/team/gator:tooling \
107+
TEST_PUSH_STATUS=1 expect_failure run_transport
108+
echo 'ok - Podman uses the pushed manifest digest and rejects missing or invalid digests'
109+
88110
: > "$CALLS"
89111
TEST_IMAGE="registry.test/team/gator@sha256:$TEST_DIGEST" run_transport > "$tmp/out"
90112
[[ ! -s "$CALLS" ]] || fail 'prebuilt path contacted local image/cluster tools'

0 commit comments

Comments
 (0)