mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 16:36:38 +00:00
gha: enable policy testing on TDX
Enable policy testing on TDX Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
This commit is contained in:
@@ -272,7 +272,7 @@ function run_tests() {
|
||||
export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"
|
||||
|
||||
# TODO: enable testing auto-generated policy for other types of hosts too.
|
||||
if [ "${KATA_HOST_OS}" = "cbl-mariner" ]; then
|
||||
if [ "${KATA_HOST_OS}" = "cbl-mariner" ] || [ "${KATA_HYPERVISOR}" = "qemu-tdx" ]; then
|
||||
export AUTO_GENERATE_POLICY="yes"
|
||||
fi
|
||||
|
||||
|
@@ -10,6 +10,7 @@ load "${BATS_TEST_DIRNAME}/tests_common.sh"
|
||||
|
||||
setup() {
|
||||
auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled."
|
||||
( [ "${KATA_HYPERVISOR}" == "qemu-tdx" ] ) && skip "https://github.com/kata-containers/kata-containers/issues/9846"
|
||||
|
||||
pod_name="policy-pod-pvc"
|
||||
pvc_name="policy-dev"
|
||||
@@ -54,6 +55,7 @@ test_pod_policy_error() {
|
||||
|
||||
teardown() {
|
||||
auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled."
|
||||
( [ "${KATA_HYPERVISOR}" == "qemu-tdx" ] ) && skip "https://github.com/kata-containers/kata-containers/issues/9846"
|
||||
|
||||
# Debugging information. Don't print the "Message:" line because it contains a truncated policy log.
|
||||
kubectl describe pod "${pod_name}" | grep -v "Message:"
|
||||
|
@@ -130,6 +130,26 @@ auto_generate_policy_enabled() {
|
||||
[ "${AUTO_GENERATE_POLICY}" == "yes" ]
|
||||
}
|
||||
|
||||
# adapt common policy settings for tdx
|
||||
adapt_common_policy_settings_for_tdx() {
|
||||
|
||||
local settings_dir=$1
|
||||
|
||||
info "Adapting common policy settings for TDX"
|
||||
jq '.common.cpath = "/run/kata-containers" | .volumes.configMap.mount_point = "^$(cpath)/$(bundle-id)-[a-z0-9]{16}-"' "${settings_dir}/genpolicy-settings.json" > temp.json && sudo mv temp.json "${settings_dir}/genpolicy-settings.json"
|
||||
}
|
||||
|
||||
# adapt common policy settings for various platforms
|
||||
adapt_common_policy_settings() {
|
||||
|
||||
local settings_dir=$1
|
||||
|
||||
case "${KATA_HYPERVISOR}" in
|
||||
"qemu-tdx")
|
||||
adapt_common_policy_settings_for_tdx "${settings_dir}"
|
||||
esac
|
||||
}
|
||||
|
||||
# If auto-generated policy testing is enabled, make a copy of the genpolicy settings,
|
||||
# and change these settings to use Kata CI cluster's default namespace.
|
||||
create_common_genpolicy_settings() {
|
||||
@@ -138,6 +158,8 @@ create_common_genpolicy_settings() {
|
||||
|
||||
auto_generate_policy_enabled || return 0
|
||||
|
||||
adapt_common_policy_settings "${default_genpolicy_settings_dir}"
|
||||
|
||||
cp "${default_genpolicy_settings_dir}/genpolicy-settings.json" "${genpolicy_settings_dir}"
|
||||
cp "${default_genpolicy_settings_dir}/rules.rego" "${genpolicy_settings_dir}"
|
||||
|
||||
|
Reference in New Issue
Block a user