@@ -39,31 +39,8 @@ sudo dnf -y clean all
39
39
40
40
old_version=$( sudo dnf info NetworkManager | grep Version | cut -d ' :' -f 2)
41
41
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."
67
44
68
45
new_version=$( sudo dnf info NetworkManager | grep Version | cut -d ' :' -f 2)
69
46
# If NetworkManager was upgraded it needs to be restarted
@@ -80,42 +57,42 @@ source /etc/os-release
80
57
# All of those are needed because we're still behind for OS support.
81
58
# passlib needs to be installed as system dependency
82
59
if [[ -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
84
61
fi
85
62
86
63
# Install ansible, other packages are installed via
87
64
# vm-setup/install-package-playbook.yml
88
65
case $DISTRO in
89
66
" centos8" |" rhel8" |" almalinux8" |" rocky8" )
90
67
# 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
92
69
if [[ $DISTRO == " centos8" ]] && [[ " $NAME " != * " Stream" * ]]; then
93
70
echo " CentOS is not supported, please switch to CentOS Stream / RHEL / Rocky / Alma"
94
71
exit 1
95
72
fi
96
73
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
98
75
elif [[ $DISTRO == " rhel8" ]]; then
99
76
# 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
101
78
if sudo subscription-manager repos --list-enabled 2>&1 | grep " ansible-2-for-rhel-8-$( uname -m) -rpms" ; then
102
79
# The packaged 2.x ansible is too old for compatibility with metal3-dev-env
103
80
sudo dnf erase -y ansible
104
81
sudo subscription-manager repos --disable=ansible-2-for-rhel-8-$( uname -m) -rpms
105
82
fi
106
83
fi
107
84
# 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
109
86
sudo alternatives --set python /usr/bin/python3.9
110
87
sudo alternatives --set python3 /usr/bin/python3.9
111
88
sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.9 1
112
89
PYTHON_DEVEL=" python39-devel"
113
90
;;
114
91
" centos9" |" rhel9" |" almalinux9" |" rocky9" )
115
- sudo dnf -y install python3-pip
92
+ dnf_with_retries -y install --nobest python3-pip
116
93
if [[ $DISTRO == " centos9" || $DISTRO == " almalinux9" || $DISTRO == " rocky9" ]] ; then
117
94
sudo dnf config-manager --set-enabled crb
118
- sudo dnf -y install epel-release
95
+ dnf_with_retries -y install --nobest epel-release
119
96
elif [[ $DISTRO == " rhel9" ]]; then
120
97
# NOTE(raukadah): If a system is subscribed to RHEL subscription then
121
98
# sudo subscription-manager identity will return exit 0 else 1.
@@ -124,7 +101,7 @@ case $DISTRO in
124
101
# enable the CRB repository
125
102
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$( arch) -rpms
126
103
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
128
105
fi
129
106
sudo ln -s /usr/bin/python3 /usr/bin/python || true
130
107
PYTHON_DEVEL=" python3-devel"
@@ -150,7 +127,7 @@ GO_VERSION=${GO_VERSION:-1.22.3}
150
127
GOARCH=$( uname -m)
151
128
if [[ $GOARCH == " aarch64" ]]; then
152
129
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
154
131
elif [[ $GOARCH == " x86_64" ]]; then
155
132
GOARCH=" amd64"
156
133
fi
@@ -178,16 +155,16 @@ popd
178
155
179
156
if [ -n " ${KNI_INSTALL_FROM_GIT} " ]; then
180
157
# zip is required for building the installer from source
181
- sudo dnf -y install zip
158
+ dnf_with_retries -y --nobest install zip
182
159
fi
183
160
184
161
# Install nfs for persistent volumes
185
162
if [ " ${PERSISTENT_IMAGEREG} " == true ] ; then
186
- sudo dnf -y install nfs-utils
163
+ dnf_with_retries -y --nobest install nfs-utils
187
164
fi
188
165
189
166
if [[ " ${NODES_PLATFORM} " == " baremetal" ]] ; then
190
- sudo dnf -y install ipmitool
167
+ dnf_with_retries -y --nobest install ipmitool
191
168
fi
192
169
193
170
# needed if we are using locally built images
0 commit comments