diff --git a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml index 01f1083bc..94c4aae7a 100644 --- a/test/cases/nvidia/manifests/daemonset-containerd-check.yaml +++ b/test/cases/nvidia/manifests/daemonset-containerd-check.yaml @@ -28,17 +28,34 @@ 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 ' "') + # 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"` + # For more details: https://github.com/containerd/containerd/blob/main/docs/cri/config.md + 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) + elif [ "$version" = "3" ]; then + sandbox_line=$(grep -E 'sandbox\s*=' /host-etc/containerd/config.toml || true) + else + echo "FAIL: unsupported containerd config version: $version" + exit 1 + fi - # 3. If sandbox_image is missing, fail explicitly - if [ -z "$sandbox_image" ]; then - echo "FAIL: no sandbox_image line found" + # 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