This repository was archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 194
CC | Run the current tests offloading the image to the guest without the forked containerd #5774
Draft
fidencio
wants to merge
10
commits into
kata-containers:CCv0
Choose a base branch
from
fidencio:topic/CC-add-job-to-test-image-pull-on-the-guest-without-forked-containerd
base: CCv0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3b93990
ci: CC | Add a new job to pull image inside the guest
fidencio b68fcb9
ci: install nydus snapshotter
efd2bbc
ci: containerd_nydus_setup
fidencio 25a9e1e
ci: CC | Add two new jobs for pull on host
fidencio 61901cb
nydus: Add a debug state to ease debug
fidencio a3528f7
agent_image: Switch order of tests 4 and 5
fidencio 5126133
tests: Registry cred for image pull
stevenhorsman c63008b
Add debug
stevenhorsman 68465da
Add snapshotter debug
stevenhorsman a3620ba
.ci: build nydus image binary
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
cidir=$(dirname "$0") | ||
source "${cidir}/../lib/common.bash" | ||
|
||
# Nydus related configurations | ||
NYDUS_SNAPSHOTTER_BINARY="/usr/local/bin/containerd-nydus-grpc" | ||
NYDUS_SNAPSHOTTER_TARFS_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-host-sharing.toml" | ||
NYDUS_SNAPSHOTTER_GUEST_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-guest-pulling.toml" | ||
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_CONFIG:-${NYDUS_SNAPSHOTTER_TARFS_CONFIG}}" | ||
NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE="${PULL_ON_HOST_EXPORT_MODE:-image_block}" | ||
|
||
echo "Configure nydus snapshotter" | ||
if [ "${IMAGE_OFFLOAD_TO_GUEST:-"no"}" == "yes" ]; then | ||
echo "Pulling image on the guest" | ||
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_GUEST_CONFIG}" | ||
else | ||
echo "Pulling image on the host | export_mode = ${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE}" | ||
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_TARFS_CONFIG}" | ||
sudo sed -i "s/export_mode = .*/export_mode = \"${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE}\"/" "$NYDUS_SNAPSHOTTER_CONFIG" | ||
fi | ||
|
||
echo "Start nydus snapshotter" | ||
systemd-cat -t snapshotter sudo "${NYDUS_SNAPSHOTTER_BINARY}" --config "${NYDUS_SNAPSHOTTER_CONFIG}" --log-to-stdout --log-level debug & | ||
|
||
echo "Configure containerd to use the nydus snapshotter" | ||
|
||
containerd_config_file="/etc/containerd/config.toml" | ||
|
||
snapshotter_socket="/run/containerd-nydus/containerd-nydus-grpc.sock" | ||
proxy_config=" [proxy_plugins.nydus]\n type = \"snapshot\"\n address = \"${snapshotter_socket}\"" | ||
snapshotter_config=" disable_snapshot_annotations = false\n snapshotter = \"nydus\"" | ||
|
||
echo -e "[proxy_plugins]" | sudo tee -a "${containerd_config_file}" | ||
echo -e "${proxy_config}" | sudo tee -a "${containerd_config_file}" | ||
|
||
sudo sed -i '/\[plugins.cri.containerd\]/a\'"${snapshotter_config}" "${containerd_config_file}" | ||
sudo systemctl restart containerd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
set -o errtrace | ||
|
||
cidir=$(dirname "$0") | ||
source "${cidir}/lib.sh" | ||
|
||
target_dir="/usr/local/" | ||
nydus_snapshotter_repo=$(get_version "externals.nydus-snapshotter.url") | ||
nydus_snapshotter_version=$(get_version "externals.nydus-snapshotter.version") | ||
nydus_snapshotter_repo_dir="${GOPATH}/src/github.com/containerd/nydus-snapshotter" | ||
nydus_snapshotter_binary_target_dir="${target_dir}/bin" | ||
nydus_snapshotter_config_target_dir="${target_dir}/share/nydus-snapshotter" | ||
|
||
nydus_image_binary_target_dir="$nydus_snapshotter_binary_target_dir" | ||
nydus_repo_dir="${GOPATH}/src/github.com/dragonflyoss/image-service" | ||
nydus_repo=${nydus_repo:-"https://github.com/dragonflyoss/image-service"} | ||
nydus_version=${nydus_version:-"main"} | ||
|
||
arch="$(uname -m)" | ||
|
||
clone_nydus_snapshotter_repo() { | ||
add_repo_to_git_safe_directory "${nydus_snapshotter_repo_dir}" | ||
|
||
if [ ! -d "${nydus_snapshotter_repo_dir}" ]; then | ||
mkdir -p "${nydus_snapshotter_repo_dir}" | ||
git clone ${nydus_snapshotter_repo} "${nydus_snapshotter_repo_dir}" || true | ||
pushd "${nydus_snapshotter_repo_dir}" | ||
git checkout "${nydus_snapshotter_version}" | ||
popd | ||
fi | ||
} | ||
|
||
clone_nydus_repo() { | ||
add_repo_to_git_safe_directory "${nydus_repo_dir}" | ||
|
||
if [ ! -d "${nydus_repo_dir}" ]; then | ||
mkdir -p "${nydus_repo_dir}" | ||
git clone ${nydus_repo} "${nydus_repo_dir}" || true | ||
if [ "$nydus_version" != "main" ];then | ||
pushd "${nydus_repo_dir}" | ||
git checkout "${nydus_version}" | ||
popd | ||
fi | ||
fi | ||
} | ||
|
||
build_nydus_snapshotter() { | ||
pushd "${nydus_snapshotter_repo_dir}" | ||
if [ "${arch}" = "s390x" ]; then | ||
export GOARCH=${arch} | ||
fi | ||
make | ||
|
||
sudo install -D -m 755 "bin/containerd-nydus-grpc" "${nydus_snapshotter_binary_target_dir}/containerd-nydus-grpc" | ||
sudo install -D -m 755 "bin/nydus-overlayfs" "${nydus_snapshotter_binary_target_dir}/nydus-overlayfs" | ||
rm -rf "${nydus_snapshotter_repo_dir}/bin" | ||
popd >/dev/null | ||
} | ||
|
||
build_nydus_image() { | ||
if [ "${arch}" = "s390x" ]; then | ||
echo "Skip to build nydus for ${arch}, it doesn't work for ${arch} now." | ||
return | ||
fi | ||
pushd "${nydus_repo_dir}" | ||
make release | ||
|
||
sudo install -D -m 755 "target/release/nydus-image" "${nydus_image_binary_target_dir}/nydus-image" | ||
rm -rf "${nydus_repo_dir}/target" | ||
popd >/dev/null | ||
} | ||
|
||
download_nydus_snapshotter_config() { | ||
tmp_dir=$(mktemp -d -t install-nydus-snapshotter-config-tmp.XXXXXXXXXX) | ||
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" | ||
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" | ||
sudo install -D -m 644 "${tmp_dir}/config-coco-guest-pulling.toml" "${nydus_snapshotter_config_target_dir}/config-coco-guest-pulling.toml" | ||
sudo install -D -m 644 "${tmp_dir}/config-coco-host-sharing.toml" "${nydus_snapshotter_config_target_dir}/config-coco-host-sharing.toml" | ||
|
||
} | ||
|
||
download_nydus_from_tarball() { | ||
if [ "${arch}" = "s390x" ]; then | ||
echo "Skip to download nydus for ${arch}, it doesn't work for ${arch} now." | ||
return | ||
fi | ||
|
||
local goarch="$(${cidir}/kata-arch.sh --golang)" | ||
local tarball_url="${nydus_repo}/releases/download/${nydus_version}/nydus-static-${nydus_version}-linux-${goarch}.tgz" | ||
echo "Download tarball from ${tarball_url}" | ||
tmp_dir=$(mktemp -d -t install-nydus-tmp.XXXXXXXXXX) | ||
curl -Ls "$tarball_url" | sudo tar xfz - -C ${tmp_dir} --strip-components=1 | ||
sudo install -D -m 755 "${tmp_dir}/nydus-image" "${target_dir}/bin/" | ||
} | ||
|
||
clone_nydus_repo | ||
#download_nydus_from_tarball | ||
clone_nydus_snapshotter_repo | ||
build_nydus_snapshotter | ||
download_nydus_snapshotter_config | ||
echo "install nydus-snapshotter successful" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ spec: | |
- name: nginx | ||
image: $IMAGE | ||
imagePullPolicy: Always | ||
imagePullSecrets: | ||
- name: cococred |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In f8cdfd2#diff-9ed0363d00e4ed02d42e6994eed9e2f806052abc3cd08d66bbb64d5c211f25a1, since it includes both host sharing and guest pulling tests, the snapshotter configuration file requires switching. This entails deleting the image
remove_test_image
used for the test and configuring the snapshotterconfigure_nydus_snapshotter
. However, the test cases here solely involve guest pulling, a better approach would be to delete the test image before running the test scripts, followed by restarting the snapshotter process. The same operation can be performed after the test concludes, rather than repeating the deletion and configuration for each testcase. However, I believe it's fine to do in every test case. So we may need to add the related functions tointegration/confidential/lib.sh
.