Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 336f44b

Browse files
ChengyuZhu6fidencio
authored andcommitted
ci: install nydus snapshotter
nydus-snapshotter / nydusd are required for the CoCo effort. Signed-off-by: ChengyuZhu6 <[email protected]>
1 parent 31193cc commit 336f44b

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

.ci/install_nydus_snapshotter.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2023 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
set -o errexit
9+
set -o nounset
10+
set -o pipefail
11+
set -o errtrace
12+
13+
cidir=$(dirname "$0")
14+
source "${cidir}/lib.sh"
15+
16+
target_dir="/usr/local/"
17+
18+
nydus_snapshotter_repo=$(get_version "externals.nydus-snapshotter.url")
19+
nydus_snapshotter_version=$(get_version "externals.nydus-snapshotter.version")
20+
nydus_snapshotter_repo_dir="${GOPATH}/src/github.com/containerd/nydus-snapshotter"
21+
nydus_snapshotter_binary_target_dir="${target_dir}/bin"
22+
nydus_snapshotter_config_target_dir="${target_dir}/share/nydus-snapshotter"
23+
24+
nydus_repo=${nydus_repo:-"https://github.com/dragonflyoss/image-service"}
25+
nydus_version=${nydus_version:-"v2.2.3"}
26+
27+
arch="$(uname -m)"
28+
29+
clone_nydus_snapshotter_repo() {
30+
add_repo_to_git_safe_directory "${nydus_snapshotter_repo_dir}"
31+
32+
if [ ! -d "${nydus_snapshotter_repo_dir}" ]; then
33+
mkdir -p "${nydus_snapshotter_repo_dir}"
34+
git clone ${nydus_snapshotter_repo} "${nydus_snapshotter_repo_dir}" || true
35+
pushd "${nydus_snapshotter_repo_dir}"
36+
git checkout "${nydus_snapshotter_version}"
37+
popd
38+
fi
39+
}
40+
41+
build_nydus_snapshotter() {
42+
pushd "${nydus_snapshotter_repo_dir}"
43+
if [ "${arch}" = "s390x" ]; then
44+
export GOARCH=${arch}
45+
fi
46+
make
47+
48+
sudo install -D -m 755 "bin/containerd-nydus-grpc" "${nydus_snapshotter_binary_target_dir}/containerd-nydus-grpc"
49+
sudo install -D -m 755 "bin/nydus-overlayfs" "${nydus_snapshotter_binary_target_dir}/nydus-overlayfs"
50+
rm -rf "${nydus_snapshotter_repo_dir}/bin"
51+
popd >/dev/null
52+
}
53+
54+
download_nydus_snapshotter_config() {
55+
tmp_dir=$(mktemp -d -t install-nydus-snapshotter-config-tmp.XXXXXXXXXX)
56+
curl -L https://raw.githubusercontent.com/containerd/nydus-snapshotter/${nydus_snapshotter_version}/misc/snapshotter/config-coco-guest-pulling.toml -o "${tmp_dir}/config-coco-guest-pulling.toml"
57+
curl -L https://raw.githubusercontent.com/containerd/nydus-snapshotter/${nydus_snapshotter_version}/misc/snapshotter/config-coco-host-sharing.toml -o "${tmp_dir}/config-coco-host-sharing.toml"
58+
sudo install -D -m 644 "${tmp_dir}/config-coco-guest-pulling.toml" "${nydus_snapshotter_config_target_dir}/config-coco-guest-pulling.toml"
59+
sudo install -D -m 644 "${tmp_dir}/config-coco-host-sharing.toml" "${nydus_snapshotter_config_target_dir}/config-coco-host-sharing.toml"
60+
61+
}
62+
63+
download_nydus_from_tarball() {
64+
if [ "${arch}" = "s390x" ]; then
65+
echo "Skip to download nydus for ${arch}, it doesn't work for ${arch} now."
66+
return
67+
fi
68+
local goarch="$(${cidir}/kata-arch.sh --golang)"
69+
local tarball_url="${nydus_repo}/releases/download/${nydus_version}/nydus-static-${nydus_version}-linux-${goarch}.tgz"
70+
echo "Download tarball from ${tarball_url}"
71+
tmp_dir=$(mktemp -d -t install-nydus-tmp.XXXXXXXXXX)
72+
curl -Ls "$tarball_url" | sudo tar xfz - -C ${tmp_dir} --strip-components=1
73+
sudo install -D -m 755 "${tmp_dir}/nydus-image" "${target_dir}/bin/"
74+
}
75+
76+
download_nydus_from_tarball
77+
clone_nydus_snapshotter_repo
78+
build_nydus_snapshotter
79+
download_nydus_snapshotter_config
80+
echo "install nydus-snapshotter successful"

.ci/lib.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,15 @@ cleanup_network_interface() {
391391
[ "$CNI" != "" ] && info "$CNI doesn't clean up"
392392
}
393393

394+
cleanup_nydus_snapshotter_dependencies() {
395+
if [ -f "/usr/local/bin/nydus-overlayfs" ]; then
396+
rm -f "/usr/local/bin/nydus-overlayfs"
397+
fi
398+
if [ -f "/usr/local/bin/nydus-image" ]; then
399+
rm -f "/usr/local/bin/nydus-image"
400+
fi
401+
}
402+
394403
gen_clean_arch() {
395404
# For metrics CI we are removing unnecessary steps like
396405
# removing packages, removing CRI-O, etc mainly because
@@ -412,6 +421,9 @@ gen_clean_arch() {
412421
fi
413422
fi
414423

424+
info "remove nydus snapshotter dependencies"
425+
cleanup_nydus_snapshotter_dependencies
426+
415427
info "remove containers started by ctr"
416428
clean_env_ctr
417429

.ci/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ install_extra_tools() {
135135
fi
136136
fi
137137

138+
if [ "${IMAGE_OFFLOAD_TO_GUEST}" == "yes" ]; then
139+
info "Install nydus-snapshotter"
140+
bash -f "${cidir}/install_nydus_snapshotter.sh"
141+
fi
142+
138143
echo "Install CNI plugins"
139144
bash -f "${cidir}/install_cni_plugins.sh"
140145
}

0 commit comments

Comments
 (0)