@@ -39,31 +39,8 @@ sudo dnf -y clean all
3939
4040old_version=$( sudo dnf info NetworkManager | grep Version | cut -d ' :' -f 2)
4141
42- # Update to latest packages first
43- # Number of attempts
44- MAX_RETRIES=5
45- # Delay between attempts (in seconds)
46- _YUM_RETRY_BACKOFF=15
47-
48- attempt=1
49- while (( attempt <= MAX_RETRIES )) ; do
50- if sudo dnf -y upgrade --nobest; then
51- echo " System upgraded successfully."
52- break
53- else
54- echo " Upgrade failed (attempt $attempt ). Cleaning cache and retrying..."
55- sudo dnf clean all
56- sudo rm -rf /var/cache/dnf/*
57- sleep $(( _YUM_RETRY_BACKOFF * attempt ))
58- fi
59-
60- (( attempt++ ))
61- done
62-
63- if (( attempt > MAX_RETRIES )) ; then
64- echo " ERROR: Failed to upgrade system after $MAX_RETRIES attempts."
65- exit 1
66- fi
42+ dnf_with_retries -y upgrade --nobest
43+ echo " System upgraded successfully."
6744
6845new_version=$( sudo dnf info NetworkManager | grep Version | cut -d ' :' -f 2)
6946# If NetworkManager was upgraded it needs to be restarted
@@ -80,42 +57,42 @@ source /etc/os-release
8057# All of those are needed because we're still behind for OS support.
8158# passlib needs to be installed as system dependency
8259if [[ -x " /usr/libexec/platform-python" ]]; then
83- sudo /usr/libexec/platform-python -m pip install passlib || sudo dnf -y install python3-pip && sudo /usr/libexec/platform-python -m pip install passlib
60+ sudo /usr/libexec/platform-python -m pip install passlib || sudo dnf_with_retries -y install --nobest python3-pip && sudo /usr/libexec/platform-python -m pip install passlib
8461fi
8562
8663# Install ansible, other packages are installed via
8764# vm-setup/install-package-playbook.yml
8865case $DISTRO in
8966 " centos8" |" rhel8" |" almalinux8" |" rocky8" )
9067 # install network-scripts package to be able to use legacy network commands
91- sudo dnf install -y network-scripts
68+ dnf_with_retries install -y --nobest network-scripts
9269 if [[ $DISTRO == " centos8" ]] && [[ " $NAME " != * " Stream" * ]]; then
9370 echo " CentOS is not supported, please switch to CentOS Stream / RHEL / Rocky / Alma"
9471 exit 1
9572 fi
9673 if [[ $DISTRO == " centos8" || $DISTRO == " almalinux8" || $DISTRO == " rocky8" ]]; then
97- sudo dnf -y install epel-release dnf --enablerepo=extras
74+ dnf_with_retries -y install --nobest epel-release dnf --enablerepo=extras
9875 elif [[ $DISTRO == " rhel8" ]]; then
9976 # Enable EPEL for python3-passlib and python3-bcrypt required by metal3-dev-env
100- sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
77+ dnf_with_retries dnf -y install --nobest https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
10178 if sudo subscription-manager repos --list-enabled 2>&1 | grep " ansible-2-for-rhel-8-$( uname -m) -rpms" ; then
10279 # The packaged 2.x ansible is too old for compatibility with metal3-dev-env
10380 sudo dnf erase -y ansible
10481 sudo subscription-manager repos --disable=ansible-2-for-rhel-8-$( uname -m) -rpms
10582 fi
10683 fi
10784 # Note recent ansible needs python >= 3.8 so we install 3.9 here
108- sudo dnf -y install python39
85+ dnf_with_retries -y install --nobest python39
10986 sudo alternatives --set python /usr/bin/python3.9
11087 sudo alternatives --set python3 /usr/bin/python3.9
11188 sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.9 1
11289 PYTHON_DEVEL=" python39-devel"
11390 ;;
11491 " centos9" |" rhel9" |" almalinux9" |" rocky9" )
115- sudo dnf -y install python3-pip
92+ dnf_with_retries -y install --nobest python3-pip
11693 if [[ $DISTRO == " centos9" || $DISTRO == " almalinux9" || $DISTRO == " rocky9" ]] ; then
11794 sudo dnf config-manager --set-enabled crb
118- sudo dnf -y install epel-release
95+ dnf_with_retries -y install --nobest epel-release
11996 elif [[ $DISTRO == " rhel9" ]]; then
12097 # NOTE(raukadah): If a system is subscribed to RHEL subscription then
12198 # sudo subscription-manager identity will return exit 0 else 1.
@@ -124,7 +101,7 @@ case $DISTRO in
124101 # enable the CRB repository
125102 sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$( arch) -rpms
126103 fi
127- sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
104+ dnf_with_retries -y install --nobest https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
128105 fi
129106 sudo ln -s /usr/bin/python3 /usr/bin/python || true
130107 PYTHON_DEVEL=" python3-devel"
@@ -150,7 +127,7 @@ GO_VERSION=${GO_VERSION:-1.22.3}
150127GOARCH=$( uname -m)
151128if [[ $GOARCH == " aarch64" ]]; then
152129 GOARCH=" arm64"
153- sudo dnf -y install $PYTHON_DEVEL libxml2-devel libxslt-devel
130+ dnf_with_retries -y install --nobest $PYTHON_DEVEL libxml2-devel libxslt-devel
154131elif [[ $GOARCH == " x86_64" ]]; then
155132 GOARCH=" amd64"
156133fi
@@ -178,16 +155,16 @@ popd
178155
179156if [ -n " ${KNI_INSTALL_FROM_GIT} " ]; then
180157 # zip is required for building the installer from source
181- sudo dnf -y install zip
158+ dnf_with_retries -y --nobest install zip
182159fi
183160
184161# Install nfs for persistent volumes
185162if [ " ${PERSISTENT_IMAGEREG} " == true ] ; then
186- sudo dnf -y install nfs-utils
163+ dnf_with_retries -y --nobest install nfs-utils
187164fi
188165
189166if [[ " ${NODES_PLATFORM} " == " baremetal" ]] ; then
190- sudo dnf -y install ipmitool
167+ dnf_with_retries -y --nobest install ipmitool
191168fi
192169
193170# needed if we are using locally built images
0 commit comments