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

Commit bbec0af

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 498570c commit bbec0af

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

.ci/install_nydus_snapshotter.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 "assets.nydus-snapshotter.url")
19+
nydus_snapshotter_version=$(get_version "assets.nydus-snapshotter.version")
20+
nydus_snapshotter_repo_dir="${GOPATH}/src/${nydus_snapshotter_repo}"
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+
sudo mkdir -p "${nydus_snapshotter_repo_dir}"
34+
sudo git clone ${nydus_snapshotter_repo_git} "${nydus_snapshotter_repo_dir}" || true
35+
pushd "${nydus_snapshotter_repo_dir}"
36+
sudo 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+
sudo -E PATH=${PATH} 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+
if [ ! -f "${target_dir}/bin/nydus-overlayfs" ]; then
51+
echo " ${target_dir}/bin/nydus-overlayfs exists, now we will replace it."
52+
sudo cp "${nydus_snapshotter_binary_target_dir}/nydus-overlayfs" "${target_dir}/bin/nydus-overlayfs"
53+
fi
54+
sudo rm -rf "${nydus_snapshotter_repo_dir}/bin"
55+
popd >/dev/null
56+
}
57+
58+
download_nydus_snapshotter_config() {
59+
tmp_dir=$(mktemp -d -t install-nydus-snapshotter-config-tmp.XXXXXXXXXX)
60+
sudo 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"
61+
sudo 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"
62+
sudo install -D -m 644 "${tmp_dir}/config-coco-guest-pulling.toml" "${nydus_snapshotter_config_target_dir}/config-coco-guest-pulling.toml"
63+
sudo install -D -m 644 "${tmp_dir}/config-coco-host-sharing.toml" "${nydus_snapshotter_config_target_dir}/config-coco-host-sharing.toml"
64+
65+
}
66+
67+
download_nydus_from_tarball() {
68+
if [ "${arch}" = "s390x" ]; then
69+
echo "Skip to download nydus for ${arch}, it doesn't work for ${arch} now."
70+
return
71+
fi
72+
local goarch="$(${cidir}/kata-arch.sh --golang)"
73+
local tarball_url="${nydus_repo}/releases/download/${nydus_version}/nydus-static-${nydus_version}-linux-${goarch}.tgz"
74+
echo "Download tarball from ${tarball_url}"
75+
tmp_dir=$(mktemp -d -t install-nydus-tmp.XXXXXXXXXX)
76+
sudo curl -Ls "$tarball_url" | sudo tar xfz - -C ${tmp_dir} --strip-components=1
77+
sudo install -D -m 755 "${tmp_dir}/nydus-image" "${target_dir}/bin/"
78+
}
79+
80+
download_nydus_from_tarball
81+
clone_nydus_snapshotter_repo
82+
build_nydus_snapshotter
83+
download_nydus_snapshotter_config
84+
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)