From 83652673b61b00486fce1bba11e12bad1e881ec9 Mon Sep 17 00:00:00 2001 From: David Porter Date: Tue, 31 Jan 2023 11:35:58 -0800 Subject: [PATCH] test: Update runtime class detection logic In the `NodeSupportsPreconfiguredRuntimeClassHandler`, update the check for the runtime handler to return a failure if the `/etc/containerd/config.toml` or `/etc/crio/crio.conf` config files do not exist. If an error is returned, then the underlying test will be skipped. Test manually with starting a kind cluster and moving the containerd config file and verifying that the test is skipped: ``` $ docker exec -it kind-worker /bin/bash root@kind-worker:/# mv /etc/containerd/config.toml /etc/containerd/config.toml.bak ``` ``` make WHAT="test/e2e/e2e.test" $ ./_output/bin/e2e.test -kubeconfig /tmp/kubeconfig_kind -ginkgo.focus=".*should run a Pod requesting a RuntimeClass with a configured handler.*" --num-nodes=1 2>&1 -ginkgo.v=1 | tee -i "/tmp/build-log.txt" [sig-node] RuntimeClass [It] should run a Pod requesting a RuntimeClass with a configured handler [NodeFeature:RuntimeHandler] test/e2e/common/node/runtimeclass.go:85 [SKIPPED] Skipping test as node does not have E2E runtime class handler preconfigured in container runtime config: command terminated with exit code 1 ``` Signed-off-by: David Porter --- test/e2e/framework/node/runtimeclass/runtimeclass.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e/framework/node/runtimeclass/runtimeclass.go b/test/e2e/framework/node/runtimeclass/runtimeclass.go index 8ec8f7ae95e..753ce651c08 100644 --- a/test/e2e/framework/node/runtimeclass/runtimeclass.go +++ b/test/e2e/framework/node/runtimeclass/runtimeclass.go @@ -69,13 +69,15 @@ func NodeSupportsPreconfiguredRuntimeClassHandler(ctx context.Context, f *framew // If the `runtimes.test-handler` substring is found in the runtime config, it is assumed that the handler is configured. cmd := fmt.Sprintf(`if [ -e '/etc/containerd/config.toml' ]; then grep -q 'runtimes.%s' /etc/containerd/config.toml - return + exit fi if [ -e '/etc/crio/crio.conf' ]; then grep -q 'runtimes.%s' /etc/crio/crio.conf - return + exit fi + +exit 1 `, PreconfiguredRuntimeClassHandler, PreconfiguredRuntimeClassHandler) _, err = hostExec.IssueCommandWithResult(ctx, cmd, node)