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

Commit 43652ea

Browse files
committed
ci: containerd_nydus_setup
Ensure nydus is setup to be used by containerd as part of our tests. Signed-off-by: Fabiano Fidêncio <[email protected]> Signed-off-by: ChengyuZhu6 <[email protected]>
1 parent 336f44b commit 43652ea

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

.ci/containerd_nydus_setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
12+
cidir=$(dirname "$0")
13+
source "${cidir}/../lib/common.bash"
14+
15+
# Nydus related configurations
16+
NYDUS_SNAPSHOTTER_BINARY="/usr/local/bin/containerd-nydus-grpc"
17+
NYDUS_SNAPSHOTTER_TARFS_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-host-sharing.toml"
18+
NYDUS_SNAPSHOTTER_GUEST_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-guest-pulling.toml"
19+
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_CONFIG:-${NYDUS_SNAPSHOTTER_TARFS_CONFIG}}"
20+
NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE="${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE:-image_block}"
21+
22+
echo "Configure nydus snapshotter"
23+
if [ "${IMAGE_OFFLOAD_TO_GUEST:-"no"}" == "yes" ]; then
24+
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_GUEST_CONFIG}"
25+
else
26+
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_TARFS_CONFIG}"
27+
sudo sed -i "s/export_mode = .*/export_mode = \"${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE}\"/" "$NYDUS_SNAPSHOTTER_CONFIG"
28+
fi
29+
30+
echo "Start nydus snapshotter"
31+
sudo "${NYDUS_SNAPSHOTTER_BINARY}" --config "${NYDUS_SNAPSHOTTER_CONFIG}" >/dev/stdout 2>&1 &

.ci/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ install_extra_tools() {
138138
if [ "${IMAGE_OFFLOAD_TO_GUEST}" == "yes" ]; then
139139
info "Install nydus-snapshotter"
140140
bash -f "${cidir}/install_nydus_snapshotter.sh"
141+
bash -f "${cidir}/containerd_nydus_setup.sh"
141142
fi
142143

143144
echo "Install CNI plugins"

integration/confidential/lib.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,32 @@ configure_cc_containerd() {
209209
waitForProcess 30 5 "sudo crictl info >/dev/null"
210210

211211
# Ensure the cc CRI handler is set.
212-
local cri_handler=$(sudo crictl info | \
213-
jq '.config.containerd.runtimes.kata.cri_handler')
214-
if [[ ! "$cri_handler" =~ cc ]]; then
215-
sudo sed -i 's/\([[:blank:]]*\)\(runtime_type = "io.containerd.kata.v2"\)/\1\2\n\1cri_handler = "cc"/' \
216-
"$containerd_conf_file"
212+
213+
if [ "${IMAGE_OFFLOAD_TO_GUEST}" == "yes" ]; then
214+
echo "Configure containerd to use the nydus snapshotter"
215+
216+
local containerd_config_dir="/etc/containerd"
217+
local containerd_config_file="${containerd_config_dir}/config.toml"
218+
219+
local snapshotter_socket="/run/containerd-nydus/containerd-nydus-grpc.sock"
220+
local proxy_config=" [proxy_plugins.nydus]\n type = \"snapshot\"\n address = \"${snapshotter_socket}\""
221+
local snapshotter_config=" disable_snapshot_annotations = false\n snapshotter = \"nydus\""
222+
223+
if ! grep -q "proxy_plugins"; then
224+
echo -e "[proxy_plugins]" | sudo tee -a "${containerd_config_file}"
225+
echo -e "${proxy_config}" | sudo tee -a "${containerd_config_file}"
226+
fi
227+
228+
if ! grep -q "${snapshotter_config}"; then
229+
sudo sed -i '/\[plugins.cri.containerd\]/a\'"${snapshotter_config}" "${containerd_config_file}"
230+
fi
231+
else
232+
local cri_handler=$(sudo crictl info | \
233+
jq '.config.containerd.runtimes.kata.cri_handler')
234+
if [[ ! "$cri_handler" =~ cc ]]; then
235+
sudo sed -i 's/\([[:blank:]]*\)\(runtime_type = "io.containerd.kata.v2"\)/\1\2\n\1cri_handler = "cc"/' \
236+
"$containerd_conf_file"
237+
fi
217238
fi
218239

219240
if [ "$(sudo crictl info | jq -r '.config.cni.confDir')" = "null" ]; then

integration/kubernetes/confidential/tests_common.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ setup_common() {
3131
configure_cc_containerd "$SAVED_CONTAINERD_CONF_FILE"
3232

3333
echo "Reconfigure Kata Containers"
34-
switch_image_service_offload on
34+
if [ "${IMAGE_OFFLOAD_TO_GUEST}" == "no" ]; then
35+
switch_image_service_offload on
36+
fi
3537
clear_kernel_params
3638
add_kernel_params "${original_kernel_params}"
3739

0 commit comments

Comments
 (0)