Last active
December 1, 2022 20:57
-
-
Save BbolroC/e4828d8f2b06ab35504867d19ab22155 to your computer and use it in GitHub Desktop.
Code changes to run a test scenario described in https://github.com/kata-containers/tests/pull/5297
This file contains 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
diff --git a/.ci/run.sh b/.ci/run.sh | |
index 2a0869da..9016d4b3 100755 | |
--- a/.ci/run.sh | |
+++ b/.ci/run.sh | |
@@ -39,12 +39,12 @@ case "${CI_JOB}" in | |
sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make qat" | |
;; | |
"CRI_CONTAINERD"|"CRI_CONTAINERD_K8S"|"CRI_CONTAINERD_K8S_DEVMAPPER"|"CC_CRI_CONTAINERD"|"CC_CRI_CONTAINERD_CLOUD_HYPERVISOR") | |
- echo "INFO: Running stability test" | |
- sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make stability" | |
- echo "INFO: Containerd checks" | |
- sudo -E PATH="$PATH" bash -c "make cri-containerd" | |
- echo "INFO: Running nydus test" | |
- sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make nydus" | |
+ #echo "INFO: Running stability test" | |
+ #sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make stability" | |
+ #echo "INFO: Containerd checks" | |
+ #sudo -E PATH="$PATH" bash -c "make cri-containerd" | |
+ #echo "INFO: Running nydus test" | |
+ #sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make nydus" | |
[[ "${CI_JOB}" =~ K8S ]] && \ | |
sudo -E PATH="$PATH" CRI_RUNTIME="containerd" bash -c "make kubernetes" | |
echo "INFO: Running vcpus test" | |
diff --git a/integration/kubernetes/init.sh b/integration/kubernetes/init.sh | |
index 8a8e15e5..ca7adbfe 100755 | |
--- a/integration/kubernetes/init.sh | |
+++ b/integration/kubernetes/init.sh | |
@@ -9,7 +9,6 @@ set -o errexit | |
set -o nounset | |
set -o pipefail | |
- | |
SCRIPT_PATH=$(dirname "$(readlink -f "$0")") | |
source "${SCRIPT_PATH}/../../.ci/lib.sh" | |
source "${SCRIPT_PATH}/../../lib/common.bash" | |
@@ -135,6 +134,7 @@ cleanup_cni_configuration() { | |
# | |
configure_network() { | |
local network_plugin_config="${1:-}" | |
+ local is_first="${2:-}" | |
local issue="https://github.com/kata-containers/tests/issues/4381" | |
if [ -z "${network_plugin_config}" ]; then | |
@@ -146,7 +146,10 @@ configure_network() { | |
fi | |
info "Use configuration file from ${network_plugin_config}" | |
kubectl apply -f "$network_plugin_config" | |
- | |
+ flannel_wait_time=10 | |
+ if [ "${is_first}" = "false" ]; then | |
+ flannel_wait_time=60 | |
+ fi | |
if [ -n "${flannel_version:-}" ]; then | |
# There is an issue hitting some CI jobs due to a bug on CRI-O that | |
# sometimes doesn't realize a new CNI configuration was installed. | |
@@ -158,7 +161,7 @@ configure_network() { | |
fi | |
local list_pods="kubectl get -n kube-system --selector app=flannel pods" | |
info "Wait for Flannel pods to show up" | |
- waitForProcess "60" "10" \ | |
+ waitForProcess "${flannel_wait_time}" "10" \ | |
"[ \$($list_pods 2>/dev/null | wc -l) -gt 0 ]" | |
local flannel_p | |
for flannel_p in $($list_pods \ | |
@@ -231,7 +234,11 @@ start_kubernetes() { | |
bash -f "${SCRIPT_PATH}/../../.ci/install_kubernetes.sh" | |
fi | |
+ info "Before installing a cluster" | |
+ ls -lah /opt/cni/bin | |
sudo -E kubeadm init --config "${kubeadm_config_file}" | |
+ info "After installing a cluster" | |
+ ls -lah /opt/cni/bin | |
mkdir -p "$HOME/.kube" | |
sudo cp "/etc/kubernetes/admin.conf" "$HOME/.kube/config" | |
@@ -274,9 +281,14 @@ start_cri_runtime_service() { | |
sudo systemctl status "${cri}" --no-pager || \ | |
die "Unable to start the ${cri} service" | |
+ if [ ! -f /opt/cni/bin/flannel ]; then | |
+ info "Plugin \"flannel\" not found, restoring it from backup" | |
+ tar xvfz /opt/plugins-backup.tar.gz -C / | |
+ fi | |
} | |
main() { | |
+ local is_first="${1:-}" | |
local arch="$("${SCRIPT_PATH}/../../.ci/kata-arch.sh")" | |
local kubernetes_version=$(get_version "externals.kubernetes.version") | |
local cri_runtime_socket="" | |
@@ -334,7 +346,7 @@ main() { | |
start_kubernetes "${kubernetes_version}" "${cri_runtime_socket}" "${cgroup_driver}" | |
info "Configure the cluster network" | |
- configure_network "${network_plugin_config}" | |
+ configure_network "${network_plugin_config}" "${is_first}" | |
# we need to ensure a few specific pods ready and running | |
info "Wait for system's pods be ready and running" | |
diff --git a/integration/kubernetes/run_kubernetes_tests.sh b/integration/kubernetes/run_kubernetes_tests.sh | |
index b92c6d7d..64f43044 100755 | |
--- a/integration/kubernetes/run_kubernetes_tests.sh | |
+++ b/integration/kubernetes/run_kubernetes_tests.sh | |
@@ -125,8 +125,18 @@ fi | |
pushd "$kubernetes_dir" | |
info "Initialize the test environment" | |
+plugin_dir="/opt/cni/bin" | |
+if [ ! -f "${plugin_dir}/flannel" ]; then | |
+ die "Cannot start testing due to lack of plugin \"flannel\"" | |
+fi | |
+if [ $(ls "${plugin_dir}" | wc -w) -gt 1 ]; then | |
+ info "Making backup for cni plugins..." | |
+ tar cvfz /opt/plugins-backup.tar.gz "${plugin_dir}" | |
+else | |
+ die "No plugins, but flannel" | |
+fi | |
wait_init_retry="30" | |
-if ! bash ./init.sh; then | |
+if ! bash ./init.sh "true"; then | |
info "Environment initialization failed. Clean up and try again." | |
if ! bash ./cleanup_env.sh; then | |
die "Failed on cleanup, it won't retry. Bailing out..." | |
@@ -138,7 +148,7 @@ if ! bash ./init.sh; then | |
info "Wait ${wait_init_retry} seconds before retry" | |
sleep "${wait_init_retry}" | |
info "Retry to initialize the test environment..." | |
- bash ./init.sh | |
+ bash ./init.sh "false" | |
fi | |
trap_on_exit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment