Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use zstd for sdk container images #950

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ci-automation/ci-config.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ GC_BUCKET="flatcar-linux"

DEFAULT_HTTP_IMAGE_URL_TEMPLATE="@PROTO@://${BUILDCACHE_SERVER}/images/@ARCH@/@VERNUM@"

if ! command -v pigz > /dev/null; then
# No PIGZ on Flatcar
PIGZ="docker run --rm -i ghcr.io/flatcar/pigz --fast"
if ! command -v zstd > /dev/null; then
# we require zstd and it is included by default on flatcar
echo >&2 "zstd could not be found. unpacking container image may fail."
fi

CI_GIT_AUTHOR="flatcar-ci"
Expand Down
14 changes: 8 additions & 6 deletions ci-automation/ci_automation_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# CI automation common functions.

source ci-automation/ci-config.env
: ${PIGZ:=pigz}
: ${docker:=docker}

: ${TEST_WORK_DIR:='__TESTS__'}
Expand Down Expand Up @@ -155,10 +154,10 @@ function docker_image_to_buildcache() {
local version="$2"

# strip potential container registry prefix
local tarball="$(basename "$image")-${version}.tar.gz"
local tarball="$(basename "$image")-${version}.tar.zst"
local id_file="$(basename "$image")-${version}.id"

$docker save "${image}":"${version}" | $PIGZ -c > "${tarball}"
$docker save "${image}":"${version}" | zstd -T0 -o "${tarball}"
# Cut the "sha256:" prefix that is present in Docker but not in Podman
$docker image inspect "${image}":"${version}" | jq -r '.[].Id' | sed 's/^sha256://' > "${id_file}"
create_digests "${SIGNER:-}" "${tarball}" "${id_file}"
Expand All @@ -180,7 +179,8 @@ function docker_commit_to_buildcache() {
function docker_image_from_buildcache() {
local name="$1"
local version="$2"
local tgz="${name}-${version}.tar.gz"
local compr="${3:-zst}"
local tgz="${name}-${version}.tar.${compr}"
pothos marked this conversation as resolved.
Show resolved Hide resolved
local id_file="${name}-${version}.id"
local id_file_url="https://${BUILDCACHE_SERVER}/containers/${version}/${id_file}"
local id_file_url_release="https://mirror.release.flatcar-linux.net/containers/${version}/${id_file}"
Expand Down Expand Up @@ -214,7 +214,8 @@ function docker_image_from_buildcache() {
--retry-connrefused --retry-max-time 60 --connect-timeout 20 \
--remote-name "${url_release}"

cat "${tgz}" | $PIGZ -d -c | $docker load
# zstd can handle zlib as well :)
zstd -d -c ${tgz} | $docker load

rm "${tgz}"
}
Expand All @@ -229,7 +230,8 @@ function docker_image_from_registry_or_buildcache() {
fi

echo "Falling back to tar ball download..." >&2
docker_image_from_buildcache "${image}" "${version}"
docker_image_from_buildcache "${image}" "${version}" zst || \
docker_image_from_buildcache "${image}" "${version}" gz
}
# --

Expand Down