Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,14 @@ ensurePodInfraContainerImage() {

pod_infra_container_image=$(get_sandbox_image)

if [ -z "${pod_infra_container_image}" ]; then
echo "Failed to recognize pod infra container image"
exit $ERR_PULL_POD_INFRA_CONTAINER_IMAGE
fi

echo "Checking if $pod_infra_container_image already exists locally..."
if ctr -n k8s.io images list -q | grep -q "^${pod_infra_container_image}$"; then
echo "Image $pod_infra_container_image already exists locally, skipping pull"
echo "Cached image details:"
return 0
fi
base_name="${pod_infra_container_image%@:*}"
Expand Down
21 changes: 15 additions & 6 deletions parts/linux/cloud-init/artifacts/cse_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1277,15 +1277,24 @@ function get_sandbox_image_from_containerd_config() {

# Extract sandbox_image value from the CRI plugin section
# The sandbox_image is typically under [plugins."io.containerd.grpc.v1.cri"]
sandbox_image=$(awk '/sandbox_image/ && /=/ {
# Remove quotes and spaces
gsub(/[" ]/, "", $3)
print $3
}' FS='=' "$config_file")
sandbox_image=$(
awk -F '=' '
/^[[:space:]]*(sandbox_image|sandbox)[[:space:]]*=/ {
val=$2
sub(/#.*/, "", val)
gsub(/^[[:space:]]*"/, "", val)
gsub(/"[[:space:]]*$/, "", val)
gsub(/^[[:space:]]+|[[:space:]]+$/, "", val)
print val
}
' "$config_file"
)

# Alternative method if the above doesn't work
if [ -z "$sandbox_image" ]; then
sandbox_image=$(grep -E '^\s*sandbox_image\s*=' "$config_file" | sed 's/.*sandbox_image\s*=\s*"\([^"]*\)".*/\1/')
sandbox_image=$(grep -E '^[[:space:]]*(sandbox_image|sandbox)[[:space:]]*=' "$config_file" | \
head -n1 | \
sed -e 's/^[^=]*=[[:space:]]*//' -e 's/[[:space:]]*#.*//' -e 's/^"//' -e 's/"$//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
fi

echo "$sandbox_image"
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+China/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+Containerd+CDI/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+Containerd+MIG/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+CustomCloud/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+OutboundTypeNil/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+SSHStatusOff/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+SSHStatusOn/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+SecurityProfile/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2204+cgroupv2/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2404+NetworkPolicy/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AKSUbuntu2404+Teleport/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AzureLinuxV2+Kata/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/AzureLinuxV3+Kata/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/CustomizedImage/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/CustomizedImageKata/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/CustomizedImageLinuxGuard/CustomData

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/Flatcar+CustomCloud+USSec/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/Flatcar+CustomCloud/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/Flatcar+CustomCloud/CustomData.inner

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/Flatcar/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/Flatcar/CustomData.inner

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/MarinerV2+CustomCloud+USNat/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/MarinerV2+CustomCloud+USSec/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/MarinerV2+CustomCloud/CustomData

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/testdata/MarinerV2+Kata/CustomData

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion spec/parts/linux/cloud-init/artifacts/cse_helpers_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ Describe 'cse_helpers.sh'
The status should be success
End

It 'get result from containerd config'
It 'get result from v1 containerd config'
cat > existing_file << EOF
version = 2
oom_score = -999
Expand All @@ -617,5 +617,35 @@ EOF
The status should be success
rm -f existing_file
End

It 'get result from v2 containerd config'
cat > existing_file << EOF
version = 2
oom_score = -999
[plugins."io.containerd.grpc.v1.cri"]
sandbox = "sandbox_image_from_containerd_config"
[metrics]
address = "0.0.0.0:10257"
EOF
When call get_sandbox_image_from_containerd_config "existing_file"
The output should eq "sandbox_image_from_containerd_config"
The status should be success
rm -f existing_file
End

It 'fails from invalid containerd config'
cat > existing_file << EOF
version = 2
oom_score = -999
[plugins."io.containerd.grpc.v1.cri"]
sandbox_xxxx = "sandbox_image_from_containerd_config"
[metrics]
address = "0.0.0.0:10257"
EOF
When call get_sandbox_image_from_containerd_config "existing_file"
The output should eq ""
The status should be success
rm -f existing_file
End
End
End
Loading