fix: should install exact containerd version from components.json#8976
fix: should install exact containerd version from components.json#8976lilypan26 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure Linux CSE installs the exact containerd package version specified in components.json, aligning runtime installation behavior with the versions recorded/validated elsewhere in AgentBaker.
Changes:
- Update
cse_install.shto pass the full containerd version string through toinstallStandaloneContainerd(instead of splitting into patch/hotfix pieces). - Refactor Ubuntu containerd install logic to use the full version string for download and deb selection.
- Adjust ShellSpec assertions to validate the selected
packageVersionstring.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
spec/parts/linux/cloud-init/artifacts/cse_install_spec.sh |
Updates ShellSpec expectations to assert packageVersion directly. |
parts/linux/cloud-init/artifacts/ubuntu/cse_install_ubuntu.sh |
Switches Ubuntu containerd install to work with full version strings and updated deb selection/download logic. |
parts/linux/cloud-init/artifacts/cse_install.sh |
Changes the containerd install call path to pass the full version string into installStandaloneContainerd. |
| # No cached deb found — download from packages.microsoft.com | ||
| logs_to_events "AKS.CSE.installContainerRuntime.downloadContainerdFromVersion" "downloadContainerdFromVersion ${packageVersion}" | ||
| containerdDebFile=$(find "${CONTAINERD_DOWNLOADS_DIR}" -maxdepth 1 -name "moby-containerd_${packageVersion}*" 2>/dev/null | sort -V | tail -n1) | ||
| if [ -z "${containerdDebFile}" ]; then | ||
| echo "Failed to locate cached containerd deb" |
| else | ||
| echo "WARNING: containerd version not found in manifest, defaulting to hardcoded." | ||
| fi | ||
| containerd_patch_version="$(echo "$containerd_version" | cut -d- -f1)" | ||
| containerd_revision="$(echo "$containerd_version" | cut -d- -f2)" | ||
| if [ -z "$containerd_patch_version" ] || [ "$containerd_patch_version" = "null" ] || [ "$containerd_revision" = "null" ]; then | ||
| echo "invalid container version: $containerd_version" | ||
| exit $ERR_CONTAINERD_INSTALL_TIMEOUT | ||
| fi | ||
| logs_to_events "AKS.CSE.installContainerRuntime.installStandaloneContainerd" "installStandaloneContainerd ${containerd_patch_version} ${containerd_revision}" | ||
| echo "in installContainerRuntime - CONTAINERD_VERSION = ${containerd_patch_version}" | ||
| logs_to_events "AKS.CSE.installContainerRuntime.installStandaloneContainerd" "installStandaloneContainerd ${containerd_version}" | ||
| echo "in installContainerRuntime - CONTAINERD_VERSION = ${containerd_version}" |
| It 'returns expected output for successful installation of fake containerd in UBUNTU 20.04' | ||
| UBUNTU_RELEASE="20.04" | ||
| containerdPackage=$(readPackage "containerd") | ||
| When call installContainerRuntime | ||
| The variable containerdMajorMinorPatchVersion should equal "1.2.3" | ||
| The variable containerdHotFixVersion should equal "" | ||
| The variable packageVersion should equal "1.2.3" | ||
| The output line 3 should equal "mock logs to events calling with AKS.CSE.installContainerRuntime.installStandaloneContainerd" | ||
| The output line 4 should equal "in installContainerRuntime - CONTAINERD_VERSION = 1.2.3" |
|
|
||
| echo "Using specified Containerd Version: ${CONTAINERD_VERSION}-${CONTAINERD_PATCH_VERSION}" | ||
| installContainerdWithAptGet "${CONTAINERD_VERSION}" "${CONTAINERD_PATCH_VERSION}" || exit $ERR_CONTAINERD_INSTALL_TIMEOUT | ||
| installContainerdWithAptGet "${CONTAINERD_VERSION}-${CONTAINERD_PATCH_VERSION}" || exit $ERR_CONTAINERD_INSTALL_TIMEOUT | ||
| } |
There was a problem hiding this comment.
1.7.33-ubuntu22.04u1-1 is an invalid version format for sure
| # packageVersion is the full version string, e.g. "2.3.2-ubuntu24.04u2" or "1.7.33-ubuntu22.04u1". | ||
| # The major.minor.patch is extracted for the apt glob pattern. | ||
| local packageVersion="$1" | ||
| mkdir -p $CONTAINERD_DOWNLOADS_DIR | ||
| # Adding updateAptWithMicrosoftPkg since AB e2e uses an older image version with uncached containerd 1.6 so it needs to download from testing repo. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
parts/linux/cloud-init/artifacts/ubuntu/cse_install_ubuntu.sh:593
- installContainerdWithAptGet unconditionally runs downloadContainerdFromVersion (which does apt update/download) before checking whether the requested moby-containerd .deb is already present in CONTAINERD_DOWNLOADS_DIR. This can break restricted-network environments (and adds avoidable latency) even when the VHD has the deb cached. Check for a cached deb first and only download if it’s missing.
# No cached deb found — download from packages.microsoft.com
logs_to_events "AKS.CSE.installContainerRuntime.downloadContainerdFromVersion" "downloadContainerdFromVersion ${packageVersion}"
containerdDebFile=$(find "${CONTAINERD_DOWNLOADS_DIR}" -maxdepth 1 -name "moby-containerd_${packageVersion}*" 2>/dev/null | sort -V | tail -n1)
if [ -z "${containerdDebFile}" ]; then
echo "Failed to locate cached containerd deb"
parts/linux/cloud-init/artifacts/cse_install.sh:102
- installContainerdWithManifestJson logs that it’s “defaulting to hardcoded” when the manifest is missing, but it never assigns a fallback value. With the updated call site, this will invoke installStandaloneContainerd with an empty/null version string, which can lead to unintended installs or hard-to-debug failures. Add explicit validation (and remove the duplicate local declaration).
if [ -f "$MANIFEST_FILEPATH" ]; then
local containerd_version
containerd_version="$(jq -r .containerd.edge "$MANIFEST_FILEPATH")"
else
echo "WARNING: containerd version not found in manifest, defaulting to hardcoded."
parts/linux/cloud-init/artifacts/ubuntu/cse_install_ubuntu.sh:621
- The comment says major.minor.patch is extracted for the apt glob pattern, but the code uses the full packageVersion as the prefix for both the apt version glob and the cached .deb filename match. Please update the comment to reflect the actual behavior (or adjust the code if the comment is the intended behavior).
# packageVersion is the full version string, e.g. "2.3.2-ubuntu24.04u2" or "1.7.33-ubuntu22.04u1".
# The major.minor.patch is extracted for the apt glob pattern.
| @@ -539,7 +537,7 @@ installContainerd() { | |||
| installContainerdFromOverride ${containerdOverrideDownloadURL} || exit $ERR_CONTAINERD_INSTALL_TIMEOUT | |||
| return 0 | |||
| fi | |||
| installContainerdWithAptGet "${containerdMajorMinorPatchVersion}" "${containerdHotFixVersion}" "${CONTAINERD_DOWNLOADS_DIR}" || exit $ERR_CONTAINERD_INSTALL_TIMEOUT | |||
| installContainerdWithAptGet "${packageVersion}" "${CONTAINERD_DOWNLOADS_DIR}" || exit $ERR_CONTAINERD_INSTALL_TIMEOUT | |||
| } | |||
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #