Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions test/cases/nvidia/manifests/daemonset-containerd-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down