From c5b4568e360a621ee01d6be210120caf0b0f9058 Mon Sep 17 00:00:00 2001 From: palashvij-msft <139835364+palashvij-msft@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:43:19 +0530 Subject: [PATCH] [BUG][Mountscript] Exit on Unsupported Distro (#146) * Bug Fix * Bug Fix Unknown Linux Distro * remove extra line * update with comments, adding AZNFS_FORCE_PACKAGE_MANAGER * syntax fix * readme edit * addressing online comments * online review * online review * review online * update * update readme * update * remove blank lines * adding error catch statement, removing centro as recog distro (for testing) * update env variable usage * addressing review comments --- README.md | 2 ++ scripts/aznfs_install.sh | 48 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c7cd897..c285d5a2 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ IP prefixes with either 2 or 3 octets can be set `f.e. 10.100 10.100.100 172.16 It starts a systemd service named **aznfswatchdog** which monitors the change in IP address for all the mounted Azure Blob NFS shares. If it detects a change in endpoint IP, aznfswatchdog will update the iptables DNAT rule and NFS traffic will be forwarded to new endpoint IP. +> [!NOTE] +> After an Azure Blob NFS endpoint is unmounted, the local proxy IP-to-endpoint mapping remains cached in the mountmap for 5 minutes. If the same endpoint is remounted within this period, it will automatically reuse the previous proxy IP address. During this period, it will ignore `AZNFS_IP_PREFIXES` environment variable if it is set. ## Limitations diff --git a/scripts/aznfs_install.sh b/scripts/aznfs_install.sh index 04b24fa2..9107bf26 100644 --- a/scripts/aznfs_install.sh +++ b/scripts/aznfs_install.sh @@ -289,6 +289,7 @@ ensure_pkg() fi apt=1 apt install -y $pkg + install_error=$? elif [ "$distro" == "centos" -o "$distro" == "rocky" -o "$distro" == "rhel" -o "$distro" == "mariner" ]; then # lsb_release package is called redhat-lsb-core in redhat/centos. if [ "$pkg" == "lsb-release" ]; then @@ -296,9 +297,49 @@ ensure_pkg() fi use_dnf_or_yum $yum install -y $pkg + install_error=$? elif [ "$distro" == "sles" ]; then zypper=1 zypper install -y $pkg + install_error=$? + elif [ -n "$AZNFS_FORCE_PACKAGE_MANAGER" ]; then + case "$AZNFS_FORCE_PACKAGE_MANAGER" in + apt) + apt=1 + wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>" + wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues." + apt install -y $pkg + install_error=$? + ;; + yum|dnf) + yum=$AZNFS_FORCE_PACKAGE_MANAGER + wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>" + wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues." + $yum install -y $pkg + install_error=$? + ;; + zypper) + zypper=1 + wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>" + wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues." + zypper install -y $pkg + install_error=$? + ;; + *) + eecho "[FATAL] Unsupported value for AZNFS_FORCE_PACKAGE_MANAGER <$AZNFS_FORCE_PACKAGE_MANAGER>. Use 'apt', 'yum', 'dnf', or 'zypper'" + exit 1 + ;; + esac + else + eecho "[FATAL] Unsupported linux distro <$distro>" + pecho "Check 'https://github.com/Azure/AZNFS-mount/blob/main/README.md#supported-distros' to see the list of supported distros" + pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest' or try running install after setting env variable 'AZNFS_FORCE_PACKAGE_MANAGER' to one of 'apt', 'yum', 'dnf', or 'zypper'" + exit 1 + fi + + if [ $install_error -ne 0 ]; then + eecho "[FATAL] Error installing $pkg (Error: $install_error)" + exit 1 fi } @@ -382,8 +423,9 @@ case "${__m}:${__s}" in distro_id=$(canonicalize_distro_id $distro_id) else eecho "[FATAL] Unknown linux distro, /etc/os-release not found!" - pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest'" + pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest' or try running install after setting env variable 'AZNFS_FORCE_PACKAGE_MANAGER' to one of 'apt', 'yum', 'dnf', or 'zypper'" pecho "If the problem persists, contact Microsoft support." + exit 1 fi ;; *) @@ -457,8 +499,8 @@ elif [ $zypper -eq 1 ]; then perform_aznfs_update else - install_cmd="yum" - current_version=$(yum info aznfs 2>/dev/null | grep "^Version" | tr -d " " | cut -d ':' -f2) + install_cmd=$yum + current_version=$($install_cmd info aznfs 2>/dev/null | grep "^Version" | tr -d " " | cut -d ':' -f2) # Without current version, auto-update cannot proceed. if [ "$RUN_MODE" == "auto-update" ] && [ -z "$current_version" ]; then eecho "Unable to retrieve the current version of AZNFS, exiting!"