-
Notifications
You must be signed in to change notification settings - Fork 247
fix: cni-plugins backward compatibility - continue #7881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7790e27
cb01226
94299c6
2ac15ec
daae386
d04709c
c5c3618
67f45bf
680e1c2
3b6d89a
cf37a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -138,8 +138,8 @@ installContainerRuntime() { | |||||||||||
| installFixedCNI() { | ||||||||||||
| # Old versions of VHDs will not have components.json. If it does not exist, we will try our best to download the hardcoded version for CNI here during provisioning. | ||||||||||||
| # Network Isolated Cluster / Bring Your Own ACR will not work with a vhd that requires a hardcoded CNI download. | ||||||||||||
| if [ ! -f "$COMPONENTS_FILEPATH" ] || [ -z "$(jq -r '.Packages[] | select(.name == "containernetworking-plugins") | .name' < $COMPONENTS_FILEPATH)" ]; then | ||||||||||||
| echo "WARNING: no containernetworking-plugins components present falling back to hard coded download of 1.4.1" | ||||||||||||
| if [ ! -f "$COMPONENTS_FILEPATH" ] || [ -z "$(jq -r '.Packages[] | select(.name == "containernetworking-plugins" or .name == "cni-plugins") | .name' < $COMPONENTS_FILEPATH)" ]; then | ||||||||||||
| echo "WARNING: no containernetworking-plugins or cni-plugins component present, falling back to hard coded download of 1.4.1" | ||||||||||||
| # handles amd64 and arm64 via CPU_ARCH | ||||||||||||
| if [ -z "${CPU_ARCH:-}" ]; then | ||||||||||||
| CPU_ARCH="$(getCPUArch)" | ||||||||||||
|
|
@@ -148,6 +148,47 @@ installFixedCNI() { | |||||||||||
| extract_tarball "${CNI_DOWNLOADS_DIR}/refcni.tar.gz" "$CNI_BIN_DIR" | ||||||||||||
| return | ||||||||||||
| fi | ||||||||||||
| #always just use what is listed in components.json so we don't have to sync. | ||||||||||||
| if [ -z "$(jq -r '.Packages[] | select(.name == "containernetworking-plugins") | .name' < $COMPONENTS_FILEPATH)" ]; then | ||||||||||||
| cniPackage=$(jq ".Packages" "$COMPONENTS_FILEPATH" | jq ".[] | select(.name == \"cni-plugins\")") || exit $ERR_CNI_VERSION_INVALID | ||||||||||||
|
|
||||||||||||
| #CNI doesn't really care about this but wanted to reuse updatePackageVersions which requires it. | ||||||||||||
| os=${UBUNTU_OS_NAME} | ||||||||||||
| if [ -z "$UBUNTU_RELEASE" ]; then | ||||||||||||
| os=${OS} | ||||||||||||
| os_version="current" | ||||||||||||
| fi | ||||||||||||
| os_version="${UBUNTU_RELEASE}" | ||||||||||||
| if isMarinerOrAzureLinux "${OS}" && [ "${IS_KATA}" = "true" ]; then | ||||||||||||
| os=${MARINER_KATA_OS_NAME} | ||||||||||||
| fi | ||||||||||||
|
||||||||||||
| fi | |
| fi | |
| if isAzureLinux "${OS}" && [ "${IS_KATA}" = "true" ]; then | |
| os=${AZURELINUX_KATA_OS_NAME} | |
| fi |
Outdated
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear comment. Line 167 says "#should change to ne" but it's not clear what "ne" means or what should be changed. This appears to be an incomplete thought or TODO that should either be completed or removed.
| #should change to ne |
Outdated
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message refers to "containerd" but this code is installing CNI plugins. The message should say "CNI plugins package versions array has more than one element" instead of "containerd package versions array has more than one element".
| echo "WARNING: containerd package versions array has more than one element. Installing the last element in the array." | |
| echo "WARNING: CNI plugins package versions array has more than one element. Installing the last element in the array." |
fseldow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation for empty PACKAGE_VERSIONS array or value. The code directly accesses PACKAGE_VERSIONS[0] without checking if the array is empty or contains the special value. Following the pattern in installContainerdWithComponentsJson (lines 77-80), this code should include a check like:
if [[ ${#PACKAGE_VERSIONS[@]} -eq 0 || ${PACKAGE_VERSIONS[0]} == "<SKIP>" ]]; then
echo "INFO: cni-plugins package versions array is either empty or the first element is <SKIP>. Skipping cni-plugins installation."
return 0
fi
Without this check, the script will fail with an unbound variable error or use an invalid version if the array is empty.
Outdated
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "iff" should be "if". The comment currently reads "Is there a ${arch} variable I can use instead of the iff" but should say "Is there a ${arch} variable I can use instead of the if".
| # Is there a ${arch} variable I can use instead of the iff | |
| # Is there a ${arch} variable I can use instead of the if |
fseldow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
fseldow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic error: This code assumes "cni-plugins" package is cached in the VHD downloads directory, but according to the VHD build script (vhdbuilder/packer/install-dependencies.sh:335-473), there is NO case handler for "cni-plugins", which means it's never downloaded or extracted during VHD build. The test file (vhdbuilder/packer/test/linux-vhd-content-test.sh:236-238) explicitly states: "cni-plugins is a special case that it is still in components.json for backward compatibility but we don't cache it."
This means the check at line 182 will always fail (directory doesn't exist), and the code will always exit with ERR_CNI_VERSION_INVALID at line 187. The entire code block (lines 152-191) appears to be attempting to handle a "cni-plugins" entry that was never installed on the VHD, making it non-functional.
If the intent is backward compatibility with old VHDs that have "containernetworking-plugins" but new CSE scripts that reference "cni-plugins", the logic is backwards. The code should check if "cni-plugins" exists in components.json AND was actually cached on the VHD during build. Since "cni-plugins" is never cached, this entire code path is broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The os_version assignment logic has a bug. Line 161 unconditionally overwrites the os_version set in line 159. This means when UBUNTU_RELEASE is empty (non-Ubuntu systems), os_version will be set to an empty string instead of "current". The logic should match the pattern used in installContainerdWithComponentsJson (lines 53-59) where os_version is only set to UBUNTU_RELEASE when it's not empty. The corrected logic should be: