Merge ~smoser/cloud-init:fix/centos-maybe-more-reliable into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: 2d0d355e74267f4e96a7a26b7f34e7ce75afa61d
Merged at revision: 5b6fd3ae353dd65e57ab138d7dca640d1c88d32c
Proposed branch: ~smoser/cloud-init:fix/centos-maybe-more-reliable
Merge into: cloud-init:master
Diff against target: 98 lines (+52/-6)
2 files modified
tools/read-dependencies (+36/-5)
tools/run-centos (+16/-1)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+332666@code.launchpad.net

Commit message

tools: make yum package installation more reliable

During continuous integration tests, we're seeing quite a lot of
unreliablity when running 'yum install'. The change here is to move to
re-trying a run of 'yum install --downloadonly' for 10 times or until
it succeeds. Then afterwards, running yum install from the cache.

This seems safer in general than just re-trying an install operation,
since we are specifically affected by the download phase failing.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:2d0d355e74267f4e96a7a26b7f34e7ce75afa61d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/432/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/432/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Bring it on home

review: Approve
Revision history for this message
Chad Smith (chad.smith) :
Revision history for this message
Scott Moser (smoser) :

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/read-dependencies b/tools/read-dependencies
2index 2a64868..421f470 100755
3--- a/tools/read-dependencies
4+++ b/tools/read-dependencies
5@@ -30,9 +30,35 @@ DISTRO_PKG_TYPE_MAP = {
6 'suse': 'suse'
7 }
8
9-DISTRO_INSTALL_PKG_CMD = {
10+MAYBE_RELIABLE_YUM_INSTALL = [
11+ 'sh', '-c',
12+ """
13+ error() { echo "$@" 1>&2; }
14+ n=0; max=10;
15+ bcmd="yum install --downloadonly --assumeyes --setopt=keepcache=1"
16+ while n=$(($n+1)); do
17+ error ":: running $bcmd $* [$n/$max]"
18+ $bcmd "$@"
19+ r=$?
20+ [ $r -eq 0 ] && break
21+ [ $n -ge $max ] && { error "gave up on $bcmd"; exit $r; }
22+ nap=$(($n*5))
23+ error ":: failed [$r] ($n/$max). sleeping $nap."
24+ sleep $nap
25+ done
26+ error ":: running yum install --cacheonly --assumeyes $*"
27+ yum install --cacheonly --assumeyes "$@"
28+ """,
29+ 'reliable-yum-install']
30+
31+DRY_DISTRO_INSTALL_PKG_CMD = {
32 'centos': ['yum', 'install', '--assumeyes'],
33 'redhat': ['yum', 'install', '--assumeyes'],
34+}
35+
36+DISTRO_INSTALL_PKG_CMD = {
37+ 'centos': MAYBE_RELIABLE_YUM_INSTALL,
38+ 'redhat': MAYBE_RELIABLE_YUM_INSTALL,
39 'debian': ['apt', 'install', '-y'],
40 'ubuntu': ['apt', 'install', '-y'],
41 'opensuse': ['zypper', 'install'],
42@@ -80,8 +106,8 @@ def get_parser():
43 help='Additionally install continuous integration system packages '
44 'required for build and test automation.')
45 parser.add_argument(
46- '-v', '--python-version', type=str, dest='python_version', default=None,
47- choices=["2", "3"],
48+ '-v', '--python-version', type=str, dest='python_version',
49+ default=None, choices=["2", "3"],
50 help='Override the version of python we want to generate system '
51 'package dependencies for. Defaults to the version of python '
52 'this script is called with')
53@@ -219,10 +245,15 @@ def pkg_install(pkg_list, distro, test_distro=False, dry_run=False):
54 '(dryrun)' if dry_run else '', ' '.join(pkg_list)))
55 install_cmd = []
56 if dry_run:
57- install_cmd.append('echo')
58+ install_cmd.append('echo')
59 if os.geteuid() != 0:
60 install_cmd.append('sudo')
61- install_cmd.extend(DISTRO_INSTALL_PKG_CMD[distro])
62+
63+ cmd = DISTRO_INSTALL_PKG_CMD[distro]
64+ if dry_run and distro in DRY_DISTRO_INSTALL_PKG_CMD:
65+ cmd = DRY_DISTRO_INSTALL_PKG_CMD[distro]
66+ install_cmd.extend(cmd)
67+
68 if distro in ['centos', 'redhat']:
69 # CentOS and Redhat need epel-release to access oauthlib and jsonschema
70 subprocess.check_call(install_cmd + ['epel-release'])
71diff --git a/tools/run-centos b/tools/run-centos
72index e87b202..d58ef3e 100755
73--- a/tools/run-centos
74+++ b/tools/run-centos
75@@ -123,7 +123,22 @@ prep() {
76 return 0
77 fi
78 error "Installing prep packages: ${needed}"
79- yum install --assumeyes ${needed}
80+ set -- $needed
81+ local n max r
82+ n=0; max=10;
83+ bcmd="yum install --downloadonly --assumeyes --setopt=keepcache=1"
84+ while n=$(($n+1)); do
85+ error ":: running $bcmd $* [$n/$max]"
86+ $bcmd "$@"
87+ r=$?
88+ [ $r -eq 0 ] && break
89+ [ $n -ge $max ] && { error "gave up on $bcmd"; exit $r; }
90+ nap=$(($n*5))
91+ error ":: failed [$r] ($n/$max). sleeping $nap."
92+ sleep $nap
93+ done
94+ error ":: running yum install --cacheonly --assumeyes $*"
95+ yum install --cacheonly --assumeyes "$@"
96 }
97
98 start_container() {

Subscribers

People subscribed via source and target branches