mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-19 07:49:17 +00:00
Merge pull request #10882 from stevenhorsman/kbs-logging-on-failure
tests: confidential: Add KBS logging
This commit is contained in:
@@ -207,3 +207,16 @@ function create_coco_pod_yaml_with_annotations() {
|
||||
set_node "${kata_pod}" "$node"
|
||||
fi
|
||||
}
|
||||
|
||||
confidential_teardown_common() {
|
||||
local node="$1"
|
||||
local node_start_time="$2"
|
||||
|
||||
# Run common teardown
|
||||
teardown_common "${node}" ${node_start_time}
|
||||
|
||||
# Also try and print the kbs logs on failure
|
||||
if [[ -n "${node_start_time}" && -z "${BATS_TEST_COMPLETED}" ]]; then
|
||||
kbs_k8s_print_logs "${node_start_time}"
|
||||
fi
|
||||
}
|
||||
|
@@ -463,6 +463,18 @@ kbs_k8s_svc_http_addr() {
|
||||
echo "http://${host}:${port}"
|
||||
}
|
||||
|
||||
kbs_k8s_print_logs() {
|
||||
local start_time="$1"
|
||||
|
||||
# Convert to iso time for kubectl
|
||||
local iso_start_time
|
||||
iso_start_time=$(date -d "${start_time}" --iso-8601=seconds)
|
||||
|
||||
echo "::group::DEBUG - kbs logs since ${start_time}"
|
||||
kubectl -n "${KBS_NS}" logs -l app=kbs --since-time="${iso_start_time}" --timestamps=true || true
|
||||
echo "::endgroup::"
|
||||
}
|
||||
|
||||
# Ensure rust is installed in the host.
|
||||
#
|
||||
# It won't install rust if it's already present, however, if the current
|
||||
|
@@ -90,5 +90,5 @@ teardown() {
|
||||
skip "Test skipped as KBS not setup"
|
||||
fi
|
||||
|
||||
teardown_common "${node}" "${node_start_time:-}"
|
||||
confidential_teardown_common "${node}" "${node_start_time:-}"
|
||||
}
|
||||
|
@@ -110,6 +110,6 @@ teardown() {
|
||||
|
||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||
|
||||
teardown_common "${node}" "${node_start_time:-}"
|
||||
confidential_teardown_common "${node}" "${node_start_time:-}"
|
||||
kubectl delete secret cococred --ignore-not-found
|
||||
}
|
||||
|
@@ -95,5 +95,5 @@ teardown() {
|
||||
|
||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||
|
||||
teardown_common "${node}" "${node_start_time:-}"
|
||||
confidential_teardown_common "${node}" "${node_start_time:-}"
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ teardown() {
|
||||
skip "Test skipped as KBS not setup"
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user