From 6b9bc3ca2e0f77d073cf0b99c2217d9f3eb9d554 Mon Sep 17 00:00:00 2001 From: Shiv Bhosale Date: Thu, 20 Nov 2025 21:16:10 +0000 Subject: [PATCH 1/3] fix: make containerd config check compatible with newer versions of containerd config --- .../manifests/daemonset-containerd-check.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml index 01f1083bc..1c2830c49 100644 --- a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml +++ b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml @@ -28,17 +28,18 @@ spec: echo "=== content read by the container ===" cat /host-etc/containerd/config.toml - # 2. Attempt to extract 'sandbox_image' from the config - # If grep returns nothing, pipefail triggers an error - # OR you can explicitly check if the variable is empty - source <(grep sandbox_image /host-etc/containerd/config.toml | tr -d ' "') - - # 3. If sandbox_image is missing, fail explicitly - if [ -z "$sandbox_image" ]; then - echo "FAIL: no sandbox_image line found" + # 2. Attempt to extract 'sandbox' from the config to be compatible with latest containerd config. + # In containerd config version = 2 expect to find pattern `sandbox_image = "registry.k8s.io/pause:3.10.1"` + # In containerd config version = 3 expect to find pattern `sandbox = 'registry.k8s.io/pause:3.10.1'` + # For more details: https://github.com/containerd/containerd/blob/main/docs/cri/config.md + sandbox_line=$(grep -E '(sandbox)\s*=' /host-etc/containerd/config.toml || true) + # 3. If no sandbox configuration is found, fail explicitly + if [ -z "$sandbox_line" ]; then + echo "FAIL: no sandbox_image or sandbox line found" echo "=== debug ===" exit 1 fi + sandbox_image=$(echo "$sandbox_line" | cut -d'"' -f2) # 4. Check that $sandbox_image references .ecr. or is provided on the instance if [[ "$sandbox_image" == "localhost"* ]]; then From 458e65be87f71953387b4a621752cb6dfe301169 Mon Sep 17 00:00:00 2001 From: Shiv Bhosale Date: Thu, 20 Nov 2025 22:01:38 +0000 Subject: [PATCH 2/3] make config check more explict depending on the version --- .../manifests/daemonset-containerd-check.yaml | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml index 1c2830c49..f254f5c69 100644 --- a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml +++ b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml @@ -28,11 +28,29 @@ spec: echo "=== content read by the container ===" cat /host-etc/containerd/config.toml - # 2. Attempt to extract 'sandbox' from the config to be compatible with latest containerd config. + # 2. Check containerd config version and look for appropriate sandbox field # In containerd config version = 2 expect to find pattern `sandbox_image = "registry.k8s.io/pause:3.10.1"` - # In containerd config version = 3 expect to find pattern `sandbox = 'registry.k8s.io/pause:3.10.1'` + # In containerd config version = 3 expect to find pattern `sandbox = "registry.k8s.io/pause:3.10.1"` # For more details: https://github.com/containerd/containerd/blob/main/docs/cri/config.md - sandbox_line=$(grep -E '(sandbox)\s*=' /host-etc/containerd/config.toml || true) + version_line=$(grep -E '^version\s*=' /host-etc/containerd/config.toml || true) + if [ -z "$version_line" ]; then + echo "FAIL: no version line found in containerd config" + exit 1 + fi + + version=$(echo "$version_line" | cut -d'=' -f2 | tr -d ' ') + echo "INFO: containerd config version = $version" + if [ "$version" = "2" ]; then + sandbox_line=$(grep -E 'sandbox_image\s*=' /host-etc/containerd/config.toml || true) + field_name="sandbox_image" + elif [ "$version" = "3" ]; then + sandbox_line=$(grep -E 'sandbox\s*=' /host-etc/containerd/config.toml || true) + field_name="sandbox" + else + echo "FAIL: unsupported containerd config version: $version" + exit 1 + fi + # 3. If no sandbox configuration is found, fail explicitly if [ -z "$sandbox_line" ]; then echo "FAIL: no sandbox_image or sandbox line found" From eb05da0f4ee5d14374d6ce4d475dc5fde7fd9676 Mon Sep 17 00:00:00 2001 From: Shiv Bhosale Date: Thu, 20 Nov 2025 23:05:54 +0000 Subject: [PATCH 3/3] rebase on main and remove unused vars --- test/cases/nvidia/manifests/daemonset-containerd-check.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml index f254f5c69..94c4aae7a 100644 --- a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml +++ b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml @@ -42,10 +42,8 @@ spec: echo "INFO: containerd config version = $version" if [ "$version" = "2" ]; then sandbox_line=$(grep -E 'sandbox_image\s*=' /host-etc/containerd/config.toml || true) - field_name="sandbox_image" elif [ "$version" = "3" ]; then sandbox_line=$(grep -E 'sandbox\s*=' /host-etc/containerd/config.toml || true) - field_name="sandbox" else echo "FAIL: unsupported containerd config version: $version" exit 1