Skip to content

Commit

Permalink
doi: manifest - leave images, enhance cleanup
Browse files Browse the repository at this point in the history
Manifest pushes where failing because underlying
layer wasn't there. Even though the buildah rmi
was erroring, there was still some deletion.

Leave the cleanup and rm after the manifest
has been pushed. Also move the the manifest
to the cleanup routine.

Rely a little less on podman/buildah cross
compatibility.
  • Loading branch information
grooverdan committed Oct 27, 2024
1 parent 4aacf27 commit 8085d16
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions scripts/docker-library-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ debugmanifest=mariadb-debug-${container_tag}-$commit
buildmanifest "$debugmanifest" "$container" --rm
trap - EXIT

buildah rmi "$origbuildimage" || echo 'ok, its not there'
buildah rmi "$debugimage" || echo 'ok, its not there'

expected=4

if [ -n "$ubi" ]; then
Expand All @@ -134,20 +131,17 @@ fi
#

manifest_image_cleanup() {
t=$1
local manifest=$1
shift
local t=$1
if [ ! -f "$t" ]; then
return
fi
# A manifest is an image type that podman can remove
podman images --filter dangling=true --format '{{.ID}} {{.Digest}}' |
while read -r line; do
id=${line% *}
digest=${line#* }
echo id="$id" digest="$digest"
if [ -n "$(jq ".manifests[].digest |select(. == \"$digest\")" <"$t")" ]; then
podman rmi "$id"
fi
done
buildah manifest rm "$manifest" || echo "already removed"
for arch in amd64 ppc64le s390x aarch64; do
buildah rm "mariadb-${tarbuildnum}-${arch}${ubi}" || echo 'trouble removing this image'
buildah rm "mariadb-debug-${tarbuildnum}-${arch}${ubi}" || echo 'trouble removing this image'
done
rm -f "$t"
}

Expand Down Expand Up @@ -179,25 +173,22 @@ if (($(buildah manifest inspect "$devmanifest" | jq '.manifests | length') >= ex
rm "$t"

buildah manifest inspect "$devmanifest" | tee "${t}"
trap 'manifest_image_cleanup "$t"' EXIT
trap 'manifest_image_cleanup "$devmanifest" "$t"' EXIT
if [ "$prod_environment" = "True" ]; then
buildah manifest push --all --rm "$devmanifest" "docker://quay.io/mariadb-foundation/mariadb-devel:${container_tag}"
echo "${container_tag}" > last_tag
else
buildah manifest rm "$devmanifest"
rm -f last_tag
fi
manifest_image_cleanup "$t"
manifest_image_cleanup "$devmanifest" "$t"

t=$(mktemp)
buildah manifest inspect "$debugmanifest" | tee "${t}"
trap 'manifest_image_cleanup "$t"' EXIT
trap 'manifest_image_cleanup "$debugmanifest" "$t"' EXIT
if [ "$prod_environment" = "True" ]; then
buildah manifest push --all --rm "$debugmanifest" "docker://quay.io/mariadb-foundation/mariadb-debug:${container_tag}"
else
buildah manifest rm "$debugmanifest"
fi
manifest_image_cleanup "$t"
manifest_image_cleanup "$debugmanifest" "$t"

buildah images
# lost and forgotten (or just didn't make enough manifest items - build failure on an arch)
Expand Down

0 comments on commit 8085d16

Please sign in to comment.