ci: Delete policy settings directory in teardown_common()

This calls delete_tmp_policy_settings_dir() from teardown_common() and
removes delete_tmp_policy_settings_dir() calls from tests when
teardown_common() is already called.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
Aurélien Bombo
2025-09-05 14:01:56 -05:00
parent efbc69a2ec
commit fec92f3ad2
16 changed files with 19 additions and 20 deletions

View File

@@ -210,9 +210,10 @@ function create_coco_pod_yaml_with_annotations() {
confidential_teardown_common() {
local node="$1"
local node_start_time="$2"
local policy_settings_dir="$3"
# Run common teardown
teardown_common "${node}" ${node_start_time}
teardown_common "${node}" ${node_start_time} "${policy_settings_dir}"
# Also try and print the kbs logs on failure
if [[ -n "${node_start_time}" && -z "${BATS_TEST_COMPLETED}" ]]; then

View File

@@ -90,5 +90,5 @@ teardown() {
skip "Test skipped as KBS not setup"
fi
confidential_teardown_common "${node}" "${node_start_time:-}"
confidential_teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -75,7 +75,5 @@ teardown() {
kubectl delete secret "$secret_name"
delete_tmp_policy_settings_dir "${pod_policy_settings_dir}"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" "${pod_policy_settings_dir}"
}

View File

@@ -110,6 +110,6 @@ teardown() {
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
confidential_teardown_common "${node}" "${node_start_time:-}"
confidential_teardown_common "${node}" "${node_start_time:-}" ""
kubectl delete secret cococred --ignore-not-found
}

View File

@@ -93,5 +93,5 @@ teardown() {
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
confidential_teardown_common "${node}" "${node_start_time:-}"
confidential_teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -146,5 +146,5 @@ teardown() {
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -238,7 +238,7 @@ teardown() {
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
kubectl delete --ignore-not-found pvc trusted-pvc
kubectl delete --ignore-not-found pv trusted-block-pv
kubectl delete --ignore-not-found storageclass local-storage

View File

@@ -192,5 +192,5 @@ teardown() {
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -42,6 +42,5 @@ teardown() {
# Debugging information
kubectl logs "$pod_name"
delete_tmp_policy_settings_dir "${policy_settings_dir}"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" "${policy_settings_dir}"
}

View File

@@ -95,5 +95,5 @@ teardown() {
# Debugging information
rm -f "${yaml_file}"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -58,5 +58,5 @@ setup() {
teardown() {
check_and_skip
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -52,9 +52,7 @@ teardown() {
rm -f ${pod_config_dir}/job-$i.yaml
done
delete_tmp_policy_settings_dir "${policy_settings_dir}"
teardown_common
teardown_common "${node}" "${node_start_time:-}" "${policy_settings_dir}"
# Delete jobs
kubectl delete jobs -l jobgroup=${job_name}

View File

@@ -33,5 +33,5 @@ setup() {
teardown() {
auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled"
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" "${policy_settings_dir}"
}

View File

@@ -55,5 +55,5 @@ teardown() {
kubectl logs ${pod}
done
teardown_common "${node}" "${node_start_time:-}"
teardown_common "${node}" "${node_start_time:-}" ""
}

View File

@@ -115,7 +115,7 @@ teardown() {
skip "Test skipped as KBS not setup"
fi
confidential_teardown_common "${node}" "${node_start_time:-}"
confidential_teardown_common "${node}" "${node_start_time:-}" ""
kubectl delete secret sealed-secret --ignore-not-found
kubectl delete secret not-sealed-secret --ignore-not-found
}

View File

@@ -379,13 +379,16 @@ pod_exec_blocked_command() {
# Parameters:
# $1 - node name where kata is installed
# $2 - start time at the node for the sake of fetching logs
# $3 - policy settings dir (can be empty)
#
teardown_common() {
local node="$1"
local node_start_time="$2"
local policy_settings_dir="$3"
kubectl describe pods
k8s_delete_all_pods_if_any_exists || true
delete_tmp_policy_settings_dir "${policy_settings_dir}"
# Print the node journal since the test start time if a bats test is not completed
if [[ -n "${node_start_time}" && -z "${BATS_TEST_COMPLETED}" ]]; then