feat: install aznfs package on AzureLinux 3.0#8084
Conversation
Signed-off-by: Mitta Sai Chaithanya <mittas@microsoft.com>
Signed-off-by: Mitta Sai Chaithanya <mittas@microsoft.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Azure Linux 3.0 support for installing the aznfs package by enabling Microsoft’s RPM repo (packages-microsoft-prod.rpm) and installing aznfs via dnf, integrating the step into the Mariner/AzureLinux VHD build flow and updating snapshot testdata accordingly.
Changes:
- Add
installAznfsPkgFromPMCto the Mariner/AzureLinux install script to download/install Microsoft repo RPM and then installaznfson Azure Linux 3.0. - Invoke
installAznfsPkgFromPMCduring VHD build for Mariner/AzureLinux images. - Regenerate multiple
pkg/agent/testdata/**/CustomDatasnapshots to reflect the updated embedded provisioning scripts.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| vhdbuilder/packer/install-dependencies.sh | Calls installAznfsPkgFromPMC during Mariner/AzureLinux VHD build. |
| parts/linux/cloud-init/artifacts/mariner/cse_install_mariner.sh | Implements installAznfsPkgFromPMC (Azure Linux 3.0-only) to install aznfs. |
| pkg/agent/testdata/Marinerv2+DisableUnattendedUpgrades=true/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/Marinerv2+DisableUnattendedUpgrades=false/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/MarinerV2+Kata/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/MarinerV2+CustomCloud/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/MarinerV2+CustomCloud+USSec/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/MarinerV2+CustomCloud+USNat/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/AzureLinuxv2+DisableUnattendedUpgrades=true/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/AzureLinuxv2+DisableUnattendedUpgrades=false/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/AzureLinuxV3+Kata/CustomData | Snapshot update reflecting new provisioning script content. |
| pkg/agent/testdata/AzureLinuxV2+Kata/CustomData | Snapshot update reflecting new provisioning script content. |
| disableDNFAutomatic | ||
| enableCheckRestart | ||
| activateNfConntrack | ||
| installAznfsPkgFromPMC |
There was a problem hiding this comment.
installAznfsPkgFromPMC is invoked for all Mariner/AzureLinux builds. Since it only supports Azure Linux 3.0, this adds extra work/log noise for other OS versions. Consider gating the call here (e.g., only call when AzureLinux && OS_VERSION==3.0) rather than relying on the function’s early return.
| installAznfsPkgFromPMC | |
| if [ "${OS}" = "${AZURELINUX_OS_NAME}" ] && [ "${OS_VERSION}" = "3.0" ]; then | |
| installAznfsPkgFromPMC | |
| fi |
| local aznfs_pkg_url="https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm" | ||
| retrycmd_curl_file 120 5 25 ${aznfs_rpm_file} ${aznfs_pkg_url} || exit $ERR_MS_PROD_DEB_DOWNLOAD_TIMEOUT | ||
| rpm -i ${aznfs_rpm_file} | ||
| dnf check-update --refresh -y |
There was a problem hiding this comment.
dnf check-update exits with status 100 when updates are available. Since install-dependencies.sh runs with set -e, this will abort the VHD build/CSE even though it’s not an error. Use dnf makecache --refresh instead, or explicitly tolerate exit code 100 (e.g., dnf check-update ... || [ $? -eq 100 ]).
| dnf check-update --refresh -y | |
| dnf check-update --refresh -y || [ $? -eq 100 ] |
| readonly aznfs_rpm_file="/tmp/packages-microsoft-prod.rpm" | ||
| local aznfs_pkg_url="https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm" | ||
| retrycmd_curl_file 120 5 25 ${aznfs_rpm_file} ${aznfs_pkg_url} || exit $ERR_MS_PROD_DEB_DOWNLOAD_TIMEOUT | ||
| rpm -i ${aznfs_rpm_file} | ||
| dnf check-update --refresh -y | ||
| export AZNFS_NONINTERACTIVE_INSTALL=1 | ||
| if ! dnf_install 30 1 600 aznfs; then | ||
| exit $ERR_APT_INSTALL_TIMEOUT | ||
| fi | ||
| rm -f ${aznfs_rpm_file} |
There was a problem hiding this comment.
readonly aznfs_rpm_file=... inside a function makes the variable globally readonly for the rest of the script execution, which can have surprising side effects if the function is called more than once or other code reuses the name. Prefer a function-scoped variable (e.g., local / local -r) and quote expansions when passing paths to commands.
| readonly aznfs_rpm_file="/tmp/packages-microsoft-prod.rpm" | |
| local aznfs_pkg_url="https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm" | |
| retrycmd_curl_file 120 5 25 ${aznfs_rpm_file} ${aznfs_pkg_url} || exit $ERR_MS_PROD_DEB_DOWNLOAD_TIMEOUT | |
| rpm -i ${aznfs_rpm_file} | |
| dnf check-update --refresh -y | |
| export AZNFS_NONINTERACTIVE_INSTALL=1 | |
| if ! dnf_install 30 1 600 aznfs; then | |
| exit $ERR_APT_INSTALL_TIMEOUT | |
| fi | |
| rm -f ${aznfs_rpm_file} | |
| local -r aznfs_rpm_file="/tmp/packages-microsoft-prod.rpm" | |
| local -r aznfs_pkg_url="https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm" | |
| retrycmd_curl_file 120 5 25 "${aznfs_rpm_file}" "${aznfs_pkg_url}" || exit $ERR_MS_PROD_DEB_DOWNLOAD_TIMEOUT | |
| rpm -i "${aznfs_rpm_file}" | |
| dnf check-update --refresh -y | |
| export AZNFS_NONINTERACTIVE_INSTALL=1 | |
| if ! dnf_install 30 1 600 aznfs; then | |
| exit $ERR_APT_INSTALL_TIMEOUT | |
| fi | |
| rm -f "${aznfs_rpm_file}" |
| rpm -i ${aznfs_rpm_file} | ||
| dnf check-update --refresh -y |
There was a problem hiding this comment.
rpm -i is not idempotent (it fails if the package is already installed) and isn’t wrapped in retry/error handling. Because this function is invoked during VHD build with set -e, a preinstalled/partial install scenario can break the build. Consider installing the repo RPM via dnf install -y <file> / dnf_install ... <file> or using rpm -Uvh --replacepkgs with appropriate error handling.
| rpm -i ${aznfs_rpm_file} | |
| dnf check-update --refresh -y | |
| if ! retrycmd_if_failure 30 5 120 dnf install -y "${aznfs_rpm_file}"; then | |
| echo "Failed to install packages-microsoft-prod repo RPM from ${aznfs_rpm_file}" | |
| exit $ERR_APT_INSTALL_TIMEOUT | |
| fi | |
| retrycmd_if_failure 10 5 60 dnf check-update --refresh -y |
| systemctl disable aznfswatchdog | ||
| systemctl stop aznfswatchdog |
There was a problem hiding this comment.
systemctl disable/stop aznfswatchdog will fail if the unit name doesn’t exist (or is masked differently), and with set -e that would abort the build/provisioning. It’s safer to guard these calls (e.g., check systemctl list-unit-files/systemctl cat first) or make them non-fatal if the unit is absent.
| systemctl disable aznfswatchdog | |
| systemctl stop aznfswatchdog | |
| systemctl disable aznfswatchdog || true | |
| systemctl stop aznfswatchdog || true |
What this PR does / why we need it:
Install aznfs package on AzureLinux 3.0
Per aznfs-mount team's recommendation, we still need to download a rpm package from PMC site, and then use dnf to install aznfs package on Azure Linux 3.0, below are the working command lines:
Which issue(s) this PR fixes:
Fixes #