Skip to content
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

feat: do not download reference CNI plugins #4597

Merged
merged 20 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions nbcparser/pkg/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ var _ = Describe("Assert generated customData and cseCmd", func() {
AssignedIdentityId: "userAssignedID",
},
NetworkConfig: &nbcontractv1.NetworkConfig{
CniPluginsUrl: "https://acs-mirror.azureedge.net/cni/cni-plugins-amd64-v0.7.6.tgz",
VnetCniPluginsUrl: "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-linux-amd64-v1.1.3.tgz",
},
GpuConfig: &nbcontractv1.GPUConfig{
Expand Down Expand Up @@ -371,7 +370,6 @@ var _ = Describe("Test NBContract compatibility from Json to CSE command", func(
Expect(o.vars["LOAD_BALANCER_SKU"]).To(Equal(""))
Expect(o.vars["NETWORK_POLICY"]).To(Equal(""))
Expect(o.vars["NETWORK_PLUGIN"]).To(Equal(""))
Expect(o.vars["CNI_PLUGINS_URL"]).To(Equal(""))
Expect(o.vars["VNET_CNI_PLUGINS_URL"]).To(Equal(""))
Expect(o.vars["GPU_NODE"]).To(Equal("false"))
Expect(o.vars["GPU_INSTANCE_PROFILE"]).To(Equal(""))
Expand Down
1 change: 0 additions & 1 deletion nbcparser/pkg/parser/templates/cse_cmd.sh.gtpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ SERVICE_PRINCIPAL_CLIENT_ID={{.AuthConfig.GetServicePrincipalId}}
NETWORK_PLUGIN={{getStringFromNetworkPluginType .GetNetworkConfig.GetNetworkPlugin}}
NETWORK_POLICY="{{getStringFromNetworkPolicyType .GetNetworkConfig.GetNetworkPolicy}}"
VNET_CNI_PLUGINS_URL={{.GetNetworkConfig.GetVnetCniPluginsUrl}}
CNI_PLUGINS_URL={{.GetNetworkConfig.GetCniPluginsUrl}}
paulgmiller marked this conversation as resolved.
Show resolved Hide resolved
CLOUDPROVIDER_BACKOFF=true
CLOUDPROVIDER_BACKOFF_MODE=v2
CLOUDPROVIDER_BACKOFF_RETRIES=6
Expand Down
1 change: 0 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ SERVICE_PRINCIPAL_CLIENT_ID={{GetParameter "servicePrincipalClientId"}}
NETWORK_PLUGIN={{GetParameter "networkPlugin"}}
NETWORK_POLICY={{GetParameter "networkPolicy"}}
VNET_CNI_PLUGINS_URL={{GetParameter "vnetCniLinuxPluginsURL"}}
CNI_PLUGINS_URL={{GetParameter "cniPluginsURL"}}
CLOUDPROVIDER_BACKOFF={{GetParameterProperty "cloudproviderConfig" "cloudProviderBackoff"}}
CLOUDPROVIDER_BACKOFF_MODE={{GetParameterProperty "cloudproviderConfig" "cloudProviderBackoffMode"}}
CLOUDPROVIDER_BACKOFF_RETRIES={{GetParameterProperty "cloudproviderConfig" "cloudProviderBackoffRetries"}}
Expand Down
2 changes: 2 additions & 0 deletions parts/linux/cloud-init/artifacts/cse_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ ERR_SYSTEMCTL_MASK_FAIL=2 # Service could not be masked by systemctl

ERR_CREDENTIAL_PROVIDER_DOWNLOAD_TIMEOUT=205 # Timeout waiting for credential provider downloads

ERR_CNI_VERSION_INVALID=206 # reference CNI (not azure cni) needs a valid version in components.json

# For both Ubuntu and Mariner, /etc/*-release should exist.
# For unit tests, the OS and OS_VERSION will be set in the unit test script.
# So whether it's if or else actually doesn't matter to our unit test.
Expand Down
58 changes: 38 additions & 20 deletions parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CC_SERVICE_IN_TMP=/opt/azure/containers/cc-proxy.service.in
CC_SOCKET_IN_TMP=/opt/azure/containers/cc-proxy.socket.in
CNI_CONFIG_DIR="/etc/cni/net.d"
CNI_BIN_DIR="/opt/cni/bin"
#TODO pull this out of componetns.json too?
CNI_DOWNLOADS_DIR="/opt/cni/downloads"
CRICTL_DOWNLOAD_DIR="/opt/crictl/downloads"
CRICTL_BIN_DIR="/usr/local/bin"
Expand Down Expand Up @@ -96,17 +97,10 @@ installNetworkPlugin() {
if [[ "${NETWORK_PLUGIN}" = "azure" ]]; then
installAzureCNI
fi
installCNI
rm -rf $CNI_DOWNLOADS_DIR &
installCNI #reference plugins. Mostly for kubenet but loopback plugin is used by containerd until containerd 2
rm -rf $CNI_DOWNLOADS_DIR &
}

downloadCNI() {
downloadDir=${1:-${CNI_DOWNLOADS_DIR}}
mkdir -p $downloadDir
CNI_PLUGINS_URL=${2:-$CNI_PLUGINS_URL}
cniTgzTmp=${CNI_PLUGINS_URL##*/}
retrycmd_get_tarball 120 5 "$downloadDir/${cniTgzTmp}" ${CNI_PLUGINS_URL} || exit $ERR_CNI_DOWNLOAD_TIMEOUT
}

downloadCredentalProvider() {
mkdir -p $CREDENTIAL_PROVIDER_DOWNLOAD_DIR
Expand Down Expand Up @@ -272,21 +266,45 @@ setupCNIDirs() {
chmod 755 $CNI_CONFIG_DIR
}

# For CNI/AzureCNI, we want to use the untar azurecni reference first. And if that doesn't exist on the vhd does the tgz?
# And if tgz is already on the vhd then just untar into CNI_BIN_DIR
# Latest VHD should have the untar, older should have the tgz. And who knows will have neither.

# Reference CNI plugins is used by kubenet and the loopback plugin used by containerd 1.0 (dependency gone in 2.0)
# 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
# Latest VHD should have the untar, older should have the tgz. And who knows will have neither.
installCNI() {
CNI_TGZ_TMP=${CNI_PLUGINS_URL##*/} # Use bash builtin ## to remove all chars ("*") up to the final "/"
CNI_DIR_TMP=${CNI_TGZ_TMP%.tgz} # Use bash builtin % to remove the .tgz to look for a folder rather than tgz

#always just use what is listed in components.json so we don't have to sync.
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 returnPackageVersions which requires it.
os=${UBUNTU_OS_NAME}
if [[ -z "$UBUNTU_RELEASE" ]]; then
os=${MARINER_OS_NAME}
os_version="current"
fi
os_version="${UBUNTU_RELEASE}"
PACKAGE_VERSIONS=()
returnPackageVersions "${cniPackage}" "${os}" "${os_version}"

#should change to ne
if [[ ${#PACKAGE_VERSIONS[@]} -gt 1 ]]; then
echo "WARNING: containerd package versions array has more than one element. Installing the last element in the array."
exit $ERR_CONTAINERD_VERSION_INVALID
fi
packageVersion=${PACKAGE_VERSIONS[0]}

# Is there a ${arch} variable I can use instead of the iff
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems CPU_ARCH will already be defined at the global scope during build, though I guess installCNI will only ever be called at runtime after Devin's changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes CPU_ARCH is already defined at the global scope

if [[ $(isARM64) == 1 ]]; then
CNI_DIR_TMP="cni-plugins-linux-arm64-v${packageVersion}"
else
CNI_DIR_TMP="cni-plugins-linux-amd64-v${packageVersion}"
fi

if [[ -d "$CNI_DOWNLOADS_DIR/${CNI_DIR_TMP}" ]]; then
mv ${CNI_DOWNLOADS_DIR}/${CNI_DIR_TMP}/* $CNI_BIN_DIR
#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.
mv ${CNI_DOWNLOADS_DIR}/${CNI_DIR_TMP}/* $CNI_BIN_DIR
else
if [[ ! -f "$CNI_DOWNLOADS_DIR/${CNI_TGZ_TMP}" ]]; then
logs_to_events "AKS.CSE.installCNI.downloadCNI" downloadCNI
fi

tar -xzf "$CNI_DOWNLOADS_DIR/${CNI_TGZ_TMP}" -C $CNI_BIN_DIR
echo "CNI tarball should already be unzipped by components.json"
exit $ERR_CNI_VERSION_INVALID
fi

chown -R root:root $CNI_BIN_DIR
Expand Down
2 changes: 0 additions & 2 deletions pkg/agent/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,8 @@ func assignKubernetesParametersfromKubernetesConfig(properties *datamodel.Proper
addValue(parametersMap, "containerRuntime", kubernetesConfig.ContainerRuntime)
addValue(parametersMap, "containerdDownloadURLBase", cloudSpecConfig.KubernetesSpecConfig.ContainerdDownloadURLBase)
if config.IsARM64 {
addValue(parametersMap, "cniPluginsURL", cloudSpecConfig.KubernetesSpecConfig.CNIARM64PluginsDownloadURL)
addValue(parametersMap, "vnetCniLinuxPluginsURL", kubernetesConfig.GetAzureCNIURLARM64Linux(cloudSpecConfig))
} else {
addValue(parametersMap, "cniPluginsURL", cloudSpecConfig.KubernetesSpecConfig.CNIPluginsDownloadURL)
addValue(parametersMap, "vnetCniLinuxPluginsURL", kubernetesConfig.GetAzureCNIURLLinux(cloudSpecConfig))
}
addValue(parametersMap, "vnetCniWindowsPluginsURL", kubernetesConfig.GetAzureCNIURLWindows(cloudSpecConfig))
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Containerd/CSECommand

Large diffs are not rendered by default.

Loading
Loading