Skip to content

fix: should install exact containerd version from components.json#8976

Open
lilypan26 wants to merge 3 commits into
mainfrom
lily/fix-containerd-install-version-matching
Open

fix: should install exact containerd version from components.json#8976
lilypan26 wants to merge 3 commits into
mainfrom
lily/fix-containerd-install-version-matching

Conversation

@lilypan26

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to pass the full containerd version string through to installStandaloneContainerd (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 packageVersion string.

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.

Comment on lines +589 to 593
# 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"
Comment on lines 101 to +105
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}"
Comment on lines 21 to 27
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"
Comment on lines 616 to 619

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
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.7.33-ubuntu22.04u1-1 is an invalid version format for sure

Comment on lines +622 to 626
# 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.
Comment thread parts/linux/cloud-init/artifacts/ubuntu/cse_install_ubuntu.sh
Copilot AI review requested due to automatic review settings July 17, 2026 22:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 530 to 541
@@ -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
}
@lilypan26
lilypan26 enabled auto-merge (squash) July 17, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants