summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2019-02-07 16:25:37 +1300
committeryatin <ykarel@redhat.com>2019-02-25 04:44:21 +0000
commit9014df94724c7b30484933f1df6aea79fbda716a (patch)
treed524cc36384fecd46825d2b9419650e34f1bbc16
parent8f0c6bf141da1740c47188737b95f347af8b69cf (diff)
Speed up execution time of yum_update.shHEADmaster
Doing a yum update with an explicit list of packages where many of those packages are already up-to-date has a significant time penalty. This change includes version comparison to remove packages from packages_for_update where the installed and available versions are identical. This change also only installs yum-plugin-priorities if it is not already installed, for some extra time saving. For a specific example of time saved, I had a centos-binary-rsyslog-base with the following timings. Without this change ------------------- packages passed to yum update: 87 packages actually updated: 11 time taken 35s With this change ------------------- packages passed to yum update: 11 packages actually updated: 11 time taken 10s This time saved should add up over all of the container images during image prepare in CI. Change-Id: Ie282acd1cdc0de8d875959ec9578122fe34f98ac
Notes
Notes (review): Code-Review+2: Bogdan Dobrelya <bdobreli@redhat.com> Workflow+1: Emilien Macchi <emilien@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 26 Feb 2019 05:17:57 +0000 Reviewed-on: https://review.openstack.org/635398 Project: openstack/ansible-role-tripleo-modify-image Branch: refs/heads/master
-rwxr-xr-xfiles/yum_update.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/files/yum_update.sh b/files/yum_update.sh
index 62c15fd..ed9546c 100755
--- a/files/yum_update.sh
+++ b/files/yum_update.sh
@@ -4,9 +4,17 @@ set -eoux pipefail
4 4
5packages_for_update= 5packages_for_update=
6if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then 6if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then
7 installed=$(rpm -qa --qf "%{NAME}\n" | sort) 7 installed_versions=$(rpm -qa --qf "%{NAME} = %{VERSION}-%{RELEASE}\n" | sort)
8 available=$(repoquery --provides --disablerepo='*' --enablerepo=$1 --qf %{NAME} -a | cut -d= -f1 | sort) 8 available_versions=$(repoquery --provides --disablerepo='*' --enablerepo=$1 -a | sort)
9 packages_for_update=$(comm -12 <(printf "%s\n" $installed) <(printf "%s\n" $available)) 9 uptodate_versions=$(comm -12 <(printf "%s\n" "$installed_versions") <(printf "%s\n" "$available_versions"))
10
11
12 installed=$(printf "%s\n" "$installed_versions" | cut -d= -f1 | sort)
13 available=$(printf "%s\n" "$available_versions" | cut -d= -f1 | sort)
14 uptodate=$(printf "%s\n" "$uptodate_versions" | cut -d= -f1 | sort)
15
16 installed_for_update=$(comm -23 <(printf "%s\n" $installed) <(printf "%s\n" $uptodate))
17 packages_for_update=$(comm -12 <(printf "%s\n" $installed_for_update) <(printf "%s\n" $available))
10fi 18fi
11 19
12if [ -z "$packages_for_update" ]; then 20if [ -z "$packages_for_update" ]; then
@@ -18,9 +26,13 @@ PKG="$(command -v dnf || command -v yum)"
18PKG_MGR="$(echo ${PKG:(-3)})" 26PKG_MGR="$(echo ${PKG:(-3)})"
19 27
20if [ $PKG_MGR == "dnf" ]; then 28if [ $PKG_MGR == "dnf" ]; then
21 $PKG install -y dnf-plugins-core 29 if ! echo $installed | grep -qw dnf-plugins-core; then
30 $PKG install -y dnf-plugins-core
31 fi
22else: 32else:
23 $PKG install -y yum-plugin-priorities 33 if ! echo $installed | grep -qw yum-plugin-priorities; then
34 $PKG install -y yum-plugin-priorities
35 fi
24fi 36fi
25$PKG -y update $packages_for_update 37$PKG -y update $packages_for_update
26rm -rf /var/cache/$PKG_MGR 38rm -rf /var/cache/$PKG_MGR