Skip to content

Commit 05d9af9

Browse files
fseldowCopilot
andauthored
fix: cni-plugins backward compatibility - continue (#7881)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 34833a6 commit 05d9af9

File tree

66 files changed

+127
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+127
-72
lines changed

parts/linux/cloud-init/artifacts/cse_install.sh

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,8 @@ installFixedCNI() {
139139
# 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.
140140
# Network Isolated Cluster / Bring Your Own ACR will not work with a vhd that requires a hardcoded CNI download.
141141
if [ ! -f "$COMPONENTS_FILEPATH" ] || [ -z "$(jq -r '.Packages[] | select(.name == "containernetworking-plugins") | .name' < $COMPONENTS_FILEPATH)" ]; then
142-
echo "WARNING: no containernetworking-plugins components present falling back to hard coded download of 1.4.1"
143-
# handles amd64 and arm64 via CPU_ARCH
144-
if [ -z "${CPU_ARCH:-}" ]; then
145-
CPU_ARCH="$(getCPUArch)"
146-
fi
147-
retrycmd_get_tarball 120 5 "${CNI_DOWNLOADS_DIR}/refcni.tar.gz" "https://${PACKAGE_DOWNLOAD_BASE_URL}/cni-plugins/v1.4.1/binaries/cni-plugins-linux-${CPU_ARCH}-v1.4.1.tgz" || exit $ERR_CNI_DOWNLOAD_TIMEOUT
148-
extract_tarball "${CNI_DOWNLOADS_DIR}/refcni.tar.gz" "$CNI_BIN_DIR"
142+
echo "WARNING: no containernetworking-plugins component present, falling back to cni-plugin"
143+
installCNILegacy
149144
return
150145
fi
151146
}
@@ -329,6 +324,66 @@ downloadAzureCNI() {
329324
retrycmd_get_tarball 120 5 "$CNI_DOWNLOADS_DIR/${CNI_TGZ_TMP}" ${VNET_CNI_PLUGINS_URL} || exit $ERR_CNI_DOWNLOAD_TIMEOUT
330325
}
331326

327+
# Reference CNI plugins is used by kubenet and the loopback plugin used by containerd 1.0 (dependency gone in 2.0)
328+
# The version used to be deteremined by RP/toggle but are now just hadcoded in vhd as they rarely change and require a node image upgrade anyways
329+
# Latest VHD should have the untar, older should have the tgz. And who knows will have neither.
330+
installCNILegacy() {
331+
# Old versions of VHDs will not have components.json. If it does not exist, we will fall back to the hardcoded download for CNI.
332+
# Network Isolated Cluster / Bring Your Own ACR will not work with a vhd that requres a hardcoded CNI download.
333+
if [ ! -f "$COMPONENTS_FILEPATH" ] || ! jq '.Packages[] | select(.name == "cni-plugins")' < $COMPONENTS_FILEPATH > /dev/null; then
334+
echo "WARNING: no cni-plugins components present falling back to hard coded download of 1.4.1. This should error eventually"
335+
# could we fail if not Ubuntu2204Gen2ContainerdPrivateKubePkg vhd? Are there others?
336+
# definitely not handling arm here.
337+
# handles amd64 and arm64 via CPU_ARCH
338+
if [ -z "${CPU_ARCH:-}" ]; then
339+
CPU_ARCH="$(getCPUArch)"
340+
fi
341+
retrycmd_get_tarball 120 5 "${CNI_DOWNLOADS_DIR}/refcni.tar.gz" "https://${PACKAGE_DOWNLOAD_BASE_URL}/cni-plugins/v1.4.1/binaries/cni-plugins-linux-${CPU_ARCH}-v1.4.1.tgz" || exit $ERR_CNI_DOWNLOAD_TIMEOUT
342+
extract_tarball "${CNI_DOWNLOADS_DIR}/refcni.tar.gz" "$CNI_BIN_DIR"
343+
return
344+
fi
345+
346+
#always just use what is listed in components.json so we don't have to sync.
347+
cniPackage=$(jq ".Packages" "$COMPONENTS_FILEPATH" | jq ".[] | select(.name == \"cni-plugins\")") || exit $ERR_CNI_VERSION_INVALID
348+
349+
#CNI doesn't really care about this but wanted to reuse updatePackageVersions which requires it.
350+
os=${UBUNTU_OS_NAME}
351+
if [ -z "$UBUNTU_RELEASE" ]; then
352+
os=${OS}
353+
os_version="current"
354+
fi
355+
os_version="${UBUNTU_RELEASE}"
356+
if isMarinerOrAzureLinux "${OS}" && [ "${IS_KATA}" = "true" ]; then
357+
os=${MARINER_KATA_OS_NAME}
358+
fi
359+
updatePackageVersions "${cniPackage}" "${os}" "${os_version}" "${OS_VARIANT}"
360+
361+
#should change to ne
362+
# shellcheck disable=SC3010
363+
if [[ ${#PACKAGE_VERSIONS[@]} -gt 1 ]]; then
364+
echo "WARNING: containerd package versions array has more than one element. Installing the last element in the array."
365+
exit $ERR_CONTAINERD_VERSION_INVALID
366+
fi
367+
packageVersion=${PACKAGE_VERSIONS[0]}
368+
369+
# Is there a ${arch} variable I can use instead of the iff
370+
if [ "$(isARM64)" -eq 1 ]; then
371+
CNI_DIR_TMP="cni-plugins-linux-arm64-v${packageVersion}"
372+
else
373+
CNI_DIR_TMP="cni-plugins-linux-amd64-v${packageVersion}"
374+
fi
375+
376+
if [ -d "$CNI_DOWNLOADS_DIR/${CNI_DIR_TMP}" ]; then
377+
#not clear to me when this would ever happen. assume its related to the line above Latest VHD should have the untar, older should have the tgz.
378+
mv ${CNI_DOWNLOADS_DIR}/${CNI_DIR_TMP}/* $CNI_BIN_DIR
379+
else
380+
echo "CNI tarball should already be unzipped by components.json"
381+
exit $ERR_CNI_VERSION_INVALID
382+
fi
383+
384+
chown -R root:root $CNI_BIN_DIR
385+
}
386+
332387
downloadCrictl() {
333388
#if $1 is empty, take ${CRICTL_DOWNLOAD_DIR} as default value. Otherwise take $1 as the value
334389
downloadDir=${1:-${CRICTL_DOWNLOAD_DIR}}

pkg/agent/testdata/AKSUbuntu2204+China/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+Containerd+CDI/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+Containerd+DevicePlugin/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+Containerd+MIG+ArtifactStreaming/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+Containerd+MIG/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+CustomCloud+USNat/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+CustomCloud+USSec/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+CustomCloud+ootcredentialprovider/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu2204+CustomCloud/CustomData

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)