Skip to content

Commit 6b9bc3c

Browse files
committed
fix: make containerd config check compatible with newer versions of containerd config
1 parent 78811ac commit 6b9bc3c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/cases/nvidia/manifests/daemonset-containerd-check.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ spec:
2828
echo "=== content read by the container ==="
2929
cat /host-etc/containerd/config.toml
3030
31-
# 2. Attempt to extract 'sandbox_image' from the config
32-
# If grep returns nothing, pipefail triggers an error
33-
# OR you can explicitly check if the variable is empty
34-
source <(grep sandbox_image /host-etc/containerd/config.toml | tr -d ' "')
35-
36-
# 3. If sandbox_image is missing, fail explicitly
37-
if [ -z "$sandbox_image" ]; then
38-
echo "FAIL: no sandbox_image line found"
31+
# 2. Attempt to extract 'sandbox' from the config to be compatible with latest containerd config.
32+
# In containerd config version = 2 expect to find pattern `sandbox_image = "registry.k8s.io/pause:3.10.1"`
33+
# In containerd config version = 3 expect to find pattern `sandbox = 'registry.k8s.io/pause:3.10.1'`
34+
# For more details: https://github.com/containerd/containerd/blob/main/docs/cri/config.md
35+
sandbox_line=$(grep -E '(sandbox)\s*=' /host-etc/containerd/config.toml || true)
36+
# 3. If no sandbox configuration is found, fail explicitly
37+
if [ -z "$sandbox_line" ]; then
38+
echo "FAIL: no sandbox_image or sandbox line found"
3939
echo "=== debug ==="
4040
exit 1
4141
fi
42+
sandbox_image=$(echo "$sandbox_line" | cut -d'"' -f2)
4243
4344
# 4. Check that $sandbox_image references .ecr. or is provided on the instance
4445
if [[ "$sandbox_image" == "localhost"* ]]; then

0 commit comments

Comments
 (0)