From 9cf9453a959d3fd93bb2b457711814a2309de362 Mon Sep 17 00:00:00 2001 From: ChengyuZhu6 Date: Mon, 1 Apr 2024 14:02:01 +0800 Subject: [PATCH] gha: fix issue in containerd switching between different snapshotters on CI we are encountering the issue (https://github.com/kata-containers/kata-containers/issues/8407) with containerd on CI is likely due to the content digest being missing from the content store, which can happen when switching between different snapshotters. To help sort it out on CI, we now clean up related snapshots or images in k8s.io namespace. Signed-off-by: ChengyuZhu6 --- tests/integration/kubernetes/gha-run.sh | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/integration/kubernetes/gha-run.sh b/tests/integration/kubernetes/gha-run.sh index 6f0717cda904..c5960b5ebc08 100755 --- a/tests/integration/kubernetes/gha-run.sh +++ b/tests/integration/kubernetes/gha-run.sh @@ -436,6 +436,33 @@ function cleanup_snapshotter() { echo "::endgroup::" } +function reset_k8s_images(){ + # we are encountering the issue (https://github.com/kata-containers/kata-containers/issues/8407) + # with containerd on CI is likely due to the content digest being missing from the content store, + # which can happen when switching between different snapshotters. + # To help sort it out, we now clean up or fetch related images in k8s.io namespace. + ctr_args="" + if [ "${KUBERNETES}" = "k3s" ]; then + ctr_args="--address /run/k3s/containerd/containerd.sock " + fi + ctr_args+="--namespace k8s.io" + ctr_command="sudo -E ctr ${ctr_args}" + pause_images=$(${ctr_command} i ls | grep 'pause' | awk '{print $1}') + for image in $pause_images; do + ${ctr_command} content fetch "$image" + done + # remove related images in k8s.io namespace + images_to_remove=( + "quay.io/sjenning/nginx:1.15-alpine" + "quay.io/prometheus/busybox:latest" + "quay.io/confidential-containers/test-images:largeimage" + ) + + for image in "${images_to_remove[@]}"; do + ${ctr_command} i remove "$image" || true + done +} + function deploy_nydus_snapshotter() { echo "::group::deploy_nydus_snapshotter" ensure_yq @@ -520,6 +547,9 @@ function deploy_nydus_snapshotter() { kubectl logs "${pods_name}" -n nydus-system kubectl describe pod "${pods_name}" -n nydus-system echo "::endgroup::" + echo "::group::reset some k8s images" + reset_k8s_images + echo "::endgroup::" } function cleanup_nydus_snapshotter() {