From f15d40f8fb7ffe9eaae10aa62d84d13e1a6d76cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 26 May 2024 19:46:30 +0200 Subject: [PATCH 1/9] kata-deploy: Fix k0s deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit k0s deployment has been broken since we moved to using `tomlq` in our scripts. The reason is that before using `tomlq` our script would, involuntarily, end up creating the file. Now, in order to fix the situation, we need to explicitly create the file and let `tomlq` add the needed content. Signed-off-by: Fabiano Fidêncio --- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 6c5f661b8..27be984a2 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -459,12 +459,13 @@ function configure_containerd_runtime() { local runtime="kata-${shim}" local configuration="configuration-${shim}" local pluginid=cri - + # if we are running k0s auto containerd.toml generation, the base template is by default version 2 # we can safely assume to reference the newer version of cri if grep -q "version = 2\>" $containerd_conf_file || [ "$1" == "k0s-worker" ] || [ "$1" == "k0s-controller" ]; then pluginid=\"io.containerd.grpc.v1.cri\" fi + local runtime_table=".plugins.${pluginid}.containerd.runtimes.\"${runtime}\"" local runtime_options_table="${runtime_table}.options" local runtime_type=\"io.containerd."${runtime}".v2\" @@ -640,6 +641,7 @@ function main() { # This works by k0s creating a special directory in /etc/k0s/containerd.d/ where user can drop-in partial containerd configuration snippets. # k0s will automatically pick up these files and adds these in containerd configuration imports list. containerd_conf_file="/etc/containerd/kata-containers.toml" + touch "$containerd_conf_file" else # runtime == containerd if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && \ From e3c2f0b0f164206d30ca08e24d5627c1475f49da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 26 May 2024 20:24:37 +0200 Subject: [PATCH 2/9] kata-cleanup: Add k0s kustomization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit k0s was added to kata-deploy, but it's kata-cleanup counterpart was never added. Let's fix it. Signed-off-by: Fabiano Fidêncio --- .../overlays/k0s/kustomization.yaml | 7 +++++++ .../overlays/k0s/mount_k0s_conf.yaml | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/kustomization.yaml create mode 100644 tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/mount_k0s_conf.yaml diff --git a/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/kustomization.yaml b/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/kustomization.yaml new file mode 100644 index 000000000..041feda2f --- /dev/null +++ b/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/kustomization.yaml @@ -0,0 +1,7 @@ + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../../base +patches: +- path: mount_k0s_conf.yaml diff --git a/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/mount_k0s_conf.yaml b/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/mount_k0s_conf.yaml new file mode 100644 index 000000000..899893bae --- /dev/null +++ b/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s/mount_k0s_conf.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kubelet-kata-cleanup + namespace: kube-system +spec: + template: + spec: + containers: + - name: kube-kata-cleanup + volumeMounts: + - name: containerd-conf + mountPath: /etc/containerd/ + volumes: + - name: containerd-conf + hostPath: + path: /etc/k0s/containerd.d/ From 556227cb5176d3974f15b8ba483e7772e3457e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 26 May 2024 19:56:29 +0200 Subject: [PATCH 3/9] tests: Add the possibility to deploy k0s / rke2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now we've only exposed the option to deploy kata-deploy for k3s and vanilla kubernetes when using containerd. However, I do need to also deploy k0s and rke2 for an internal CI, and having those exposed here do not hurt, and allow us to easily expand the CI at any time in the future. Signed-off-by: Fabiano Fidêncio --- tests/integration/kubernetes/gha-run.sh | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/integration/kubernetes/gha-run.sh b/tests/integration/kubernetes/gha-run.sh index 9f8192ea6..394fe5bb2 100755 --- a/tests/integration/kubernetes/gha-run.sh +++ b/tests/integration/kubernetes/gha-run.sh @@ -235,11 +235,12 @@ function deploy_kata() { echo "::endgroup::" kubectl apply -f "${tools_dir}/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" - if [ "${KUBERNETES}" = "k3s" ]; then - kubectl apply -k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s" - else - kubectl apply -f "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" - fi + case "${KUBERNETES}" in + k0s) kubectl apply -k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k0s" ;; + k3s) kubectl apply -k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s" ;; + rke2) kubectl apply -k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/rke2" ;; + *) kubectl apply -f "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" + esac local cmd="kubectl -n kube-system get -l name=kata-deploy pod 2>/dev/null | grep '\'" waitForProcess "${KATA_DEPLOY_WAIT_TIMEOUT}" 10 "$cmd" @@ -388,13 +389,24 @@ function collect_artifacts() { function cleanup_kata_deploy() { ensure_yq - if [ "${KUBERNETES}" = "k3s" ]; then - deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s"" - cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/k3s"" - else - deploy_spec="-f "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"" - cleanup_spec="-f "${tools_dir}/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"" - fi + case "${KUBERNETES}" in + k0s) + deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k0s"" + cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/k0s"" + ;; + k3s) + deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s"" + cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/k3s"" + ;; + rke2) + deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/rke2"" + cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/rke2"" + ;; + *) + deploy_spec="-f "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"" + cleanup_spec="-f "${tools_dir}/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"" + ;; + esac # shellcheck disable=2086 kubectl delete ${deploy_spec} From ee2ef0641cc61e59b5dbfcb31503017c60c6feb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 26 May 2024 21:25:18 +0200 Subject: [PATCH 4/9] tests: k8s: Allow passing "all" to run all the tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently only "baremetal" runs all the tests, but we could easily run "all" locally or using the github provided runners, even when not using a "baremetal" system. The reason I'd like to have a differentiation between "all" and "baremetal" is because "baremetal" may require some cleanup, which "all" can simply skip if testing against a fresh created VM. Signed-off-by: Fabiano Fidêncio --- tests/integration/kubernetes/run_kubernetes_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/kubernetes/run_kubernetes_tests.sh b/tests/integration/kubernetes/run_kubernetes_tests.sh index 6ef8c4ccb..81c572773 100755 --- a/tests/integration/kubernetes/run_kubernetes_tests.sh +++ b/tests/integration/kubernetes/run_kubernetes_tests.sh @@ -86,12 +86,12 @@ else normal) K8S_TEST_UNION=(${K8S_TEST_NORMAL_HOST_UNION[@]}) ;; - baremetal) + all|baremetal) K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]} ${K8S_TEST_NORMAL_HOST_UNION[@]}) ;; *) - echo "${K8S_TEST_HOST_TYPE} is an invalid K8S_TEST_HOST_TYPE option. Valid options are: small | normal | baremetal" + echo "${K8S_TEST_HOST_TYPE} is an invalid K8S_TEST_HOST_TYPE option. Valid options are: small | normal | all | baremetal" return 1 ;; esac From dbd0d4a09070c30b7f01297315815e7bfd8afe5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 26 May 2024 21:30:46 +0200 Subject: [PATCH 5/9] gha: Only do preventive cleanups for baremetal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This takes a few minutes that could be saved, so let's avoid doing this on all the platforms, but simply do this when it's needed (the baremetal use case). Signed-off-by: Fabiano Fidêncio --- tests/integration/kubernetes/gha-run.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/kubernetes/gha-run.sh b/tests/integration/kubernetes/gha-run.sh index 394fe5bb2..79ff352ac 100755 --- a/tests/integration/kubernetes/gha-run.sh +++ b/tests/integration/kubernetes/gha-run.sh @@ -151,7 +151,9 @@ function deploy_kata() { [ "$platform" = "kcli" ] && \ export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig" - cleanup_kata_deploy || true + if [ "${K8S_TEST_HOST_TYPE}" = "baremetal" ]; then + cleanup_kata_deploy || true + fi set_default_cluster_namespace @@ -499,7 +501,9 @@ function deploy_nydus_snapshotter() { git clone -b "${nydus_snapshotter_version}" "${nydus_snapshotter_url}" "${nydus_snapshotter_install_dir}" pushd "$nydus_snapshotter_install_dir" - cleanup_nydus_snapshotter || true + if [ "${K8S_TEST_HOST_TYPE}" = "baremetal" ]; then + cleanup_nydus_snapshotter || true + fi if [ "${PULL_TYPE}" == "guest-pull" ]; then # Enable guest pull feature in nydus snapshotter yq write -i \ From 47d9589e9b0b09efc55c59d3b5421bcd0e10b607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 27 May 2024 04:59:54 +0200 Subject: [PATCH 6/9] tests: kata-deploy: Show output of passing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help us to debug failures and compare passing and failures outputs. Signed-off-by: Fabiano Fidêncio --- tests/functional/kata-deploy/run-kata-deploy-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/kata-deploy/run-kata-deploy-tests.sh b/tests/functional/kata-deploy/run-kata-deploy-tests.sh index 859bebf2e..a071e204a 100644 --- a/tests/functional/kata-deploy/run-kata-deploy-tests.sh +++ b/tests/functional/kata-deploy/run-kata-deploy-tests.sh @@ -21,5 +21,5 @@ fi info "Run tests" for KATA_DEPLOY_TEST_ENTRY in ${KATA_DEPLOY_TEST_UNION[@]} do - bats "${KATA_DEPLOY_TEST_ENTRY}" + bats --show-output-of-passing-tests "${KATA_DEPLOY_TEST_ENTRY}" done From 8a8a7ea0e5972bf2febe044f6ae38586b6eab436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 27 May 2024 05:04:13 +0200 Subject: [PATCH 7/9] tests: kata-deploy: Show more logs in the setup() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will also help us to better understand possible failures with the CI. Signed-off-by: Fabiano Fidêncio --- tests/functional/kata-deploy/kata-deploy.bats | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/functional/kata-deploy/kata-deploy.bats b/tests/functional/kata-deploy/kata-deploy.bats index b0b6ffc61..35d3d9e82 100644 --- a/tests/functional/kata-deploy/kata-deploy.bats +++ b/tests/functional/kata-deploy/kata-deploy.bats @@ -85,6 +85,14 @@ setup() { # Give some time for the pod to finish what's doing and have the # runtimeclasses properly created sleep 30s + + echo "::group::kata-deploy logs" + kubectl -n kube-system logs --tail=100 -l name=kata-deploy + echo "::endgroup::" + + echo "::group::Runtime classes" + kubectl get runtimeclass + echo "::endgroup::" } @test "Test runtimeclasses are being properly created and container runtime not broken" { @@ -113,8 +121,6 @@ setup() { } teardown() { - kubectl get runtimeclasses -o name | grep -v "kata-mshv-vm-isolation" - if [ "${KUBERNETES}" = "k0s" ]; then deploy_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/k0s\"" cleanup_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s\"" From fba5793c0d733285bf1548ab9bfa522effc2de68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 27 May 2024 05:53:14 +0200 Subject: [PATCH 8/9] tests: kata-deploy: Run the tests from "${repo_root_dir}" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's see if it helps with issues like: ``` error: must build at directory: not a valid directory: evalsymlink failure on '"/home/runner/actions-runner/_work/kata-containers/kata-containers/tests/functional/kata-deploy/../../..//tools/packaging/kata-deploy/kata-cleanup/overlays/k0s"' : lstat /home/runner/actions-runner/_work/kata-containers/kata-containers/tests/functional/kata-deploy/": no such file or directory ``` Signed-off-by: Fabiano Fidêncio --- tests/functional/kata-deploy/kata-deploy.bats | 71 ++++++++++--------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/tests/functional/kata-deploy/kata-deploy.bats b/tests/functional/kata-deploy/kata-deploy.bats index 35d3d9e82..4b7d904e7 100644 --- a/tests/functional/kata-deploy/kata-deploy.bats +++ b/tests/functional/kata-deploy/kata-deploy.bats @@ -11,6 +11,8 @@ setup() { repo_root_dir="${BATS_TEST_DIRNAME}/../../../" ensure_yq + pushd "${repo_root_dir}" + # We expect 2 runtime classes because: # * `kata` is the default runtimeclass created, basically an alias for `kata-${KATA_HYPERVISOR}`. # * `kata-${KATA_HYPERVISOR}` is the other one @@ -24,59 +26,59 @@ setup() { ) # Set the latest image, the one generated as part of the PR, to be used as part of the tests - sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" + sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" # Enable debug for Kata Containers yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[1].value' \ --tag '!!str' "true" # Create the runtime class only for the shim that's being tested yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[2].value' \ "${KATA_HYPERVISOR}" # Set the tested hypervisor as the default `kata` shim yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[3].value' \ "${KATA_HYPERVISOR}" # Let the `kata-deploy` script take care of the runtime class creation / removal yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[4].value' \ --tag '!!str' "true" # Let the `kata-deploy` create the default `kata` runtime class yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[5].value' \ --tag '!!str' "true" if [ "${KATA_HOST_OS}" = "cbl-mariner" ]; then yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[+].name' \ "HOST_OS" yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[-1].value' \ "${KATA_HOST_OS}" fi echo "::group::Final kata-deploy.yaml that is used in the test" - cat "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" - grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" || die "Failed to setup the tests image" + cat "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" + grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" || die "Failed to setup the tests image" echo "::endgroup::" - kubectl apply -f "${repo_root_dir}/tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" + kubectl apply -f "tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" if [ "${KUBERNETES}" = "k0s" ]; then - kubectl apply -k "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/k0s" + kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/k0s" elif [ "${KUBERNETES}" = "k3s" ]; then - kubectl apply -k "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/k3s" + kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/k3s" elif [ "${KUBERNETES}" = "rke2" ]; then - kubectl apply -k "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/rke2" + kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/rke2" else - kubectl apply -f "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" + kubectl apply -f "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" fi local cmd="kubectl -n kube-system get -l name=kata-deploy pod 2>/dev/null | grep '\'" @@ -93,6 +95,8 @@ setup() { echo "::group::Runtime classes" kubectl get runtimeclass echo "::endgroup::" + + popd } @test "Test runtimeclasses are being properly created and container runtime not broken" { @@ -117,22 +121,23 @@ setup() { # Check that the container runtime verison doesn't have unknown, which happens when containerd can't start properly container_runtime_version=$(kubectl get nodes --no-headers -o custom-columns=CONTAINER_RUNTIME:.status.nodeInfo.containerRuntimeVersion) [[ ${container_runtime_version} != *"containerd://Unknown"* ]] - } teardown() { + pushd "${repo_root_dir}" + if [ "${KUBERNETES}" = "k0s" ]; then - deploy_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/k0s\"" - cleanup_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/overlays/k0s\"" + deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/k0s\"" + cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/k0s\"" elif [ "${KUBERNETES}" = "k3s" ]; then - deploy_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/k3s\"" - cleanup_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/overlays/k3s\"" + deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/k3s\"" + cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/k3s\"" elif [ "${KUBERNETES}" = "rke2" ]; then - deploy_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/overlays/rke2\"" - cleanup_spec="-k \"${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/overlays/rke2\"" + deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/rke2\"" + cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/rke2\"" else - deploy_spec="-f \"${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml\"" - cleanup_spec="-f \"${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml\"" + deploy_spec="-f \"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml\"" + cleanup_spec="-f \"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml\"" fi kubectl delete ${deploy_spec} @@ -140,32 +145,34 @@ teardown() { # Let the `kata-deploy` script take care of the runtime class creation / removal yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ + "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ 'spec.template.spec.containers[0].env[4].value' \ --tag '!!str' "true" # Create the runtime class only for the shim that's being tested yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ + "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ 'spec.template.spec.containers[0].env[2].value' \ "${KATA_HYPERVISOR}" # Set the tested hypervisor as the default `kata` shim yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ + "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" \ 'spec.template.spec.containers[0].env[3].value' \ "${KATA_HYPERVISOR}" # Let the `kata-deploy` create the default `kata` runtime class yq write -i \ - "${repo_root_dir}/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ + "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" \ 'spec.template.spec.containers[0].env[5].value' \ --tag '!!str' "true" - sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" - cat "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" - grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "${repo_root_dir}/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" || die "Failed to setup the tests image" + sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" + cat "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" + grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" || die "Failed to setup the tests image" kubectl apply ${cleanup_spec} sleep 30s kubectl delete ${cleanup_spec} - kubectl delete -f "${repo_root_dir}/tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" + kubectl delete -f "tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" + + popd } From e81e8a4527e90764f26580ee096e25a0cfa22c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 27 May 2024 05:54:54 +0200 Subject: [PATCH 9/9] tests: kata-deploy: Adjust timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 10 minutes is waay too long. Let's give it 4 minutes only. Signed-off-by: Fabiano Fidêncio --- tests/functional/kata-deploy/kata-deploy.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/kata-deploy/kata-deploy.bats b/tests/functional/kata-deploy/kata-deploy.bats index 4b7d904e7..8969eac79 100644 --- a/tests/functional/kata-deploy/kata-deploy.bats +++ b/tests/functional/kata-deploy/kata-deploy.bats @@ -82,7 +82,7 @@ setup() { fi local cmd="kubectl -n kube-system get -l name=kata-deploy pod 2>/dev/null | grep '\'" - waitForProcess 600 10 "$cmd" + waitForProcess 240 10 "$cmd" # Give some time for the pod to finish what's doing and have the # runtimeclasses properly created