summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Stanley <fungi@yuggoth.org>2017-12-11 18:16:28 +0000
committerJeremy Stanley <fungi@yuggoth.org>2017-12-11 21:28:24 +0000
commit9e2a5d4633075a3938d1aca4c1ecf980bf7c3975 (patch)
tree3308e7cba16ef173a7d67b53307a3d76ebb0e1ec
parent69150752a0a870e8a11835e4900e599d063c4474 (diff)
Install/upgrade subunit2sql safely
When installing or upgrading subunit2sql, override pip's default upgrade strategy to avoid updating preinstalled dependencies if they already satisfy the requirements. This in particular avoids attempting to replace the distro package of python-netifaces by rebuilding a newer sdist (it is not distributed as a wheel on PyPI and needs C extensions compiled, which in turn have a lot of build-time deps). This implementation is copied from the puppet-zuul module. Change-Id: I885a61527ca9938200fb965ea97ff957fed3c480
Notes
Notes (review): Code-Review+2: Matthew Treinish <mtreinish@kortar.org> Code-Review+2: Ian Wienand <iwienand@redhat.com> Workflow+1: Ian Wienand <iwienand@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 11 Dec 2017 23:25:25 +0000 Reviewed-on: https://review.openstack.org/527203 Project: openstack-infra/puppet-subunit2sql Branch: refs/heads/master
-rw-r--r--manifests/init.pp20
-rw-r--r--manifests/server.pp2
-rw-r--r--manifests/worker.pp2
3 files changed, 17 insertions, 7 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 3685700..50e45f5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -37,10 +37,20 @@ class subunit2sql (
37 require => Class['pip'], 37 require => Class['pip'],
38 } 38 }
39 39
40 package { 'subunit2sql': 40 exec { 'install-subunit2sql-safely':
41 ensure => latest, 41 command => '/usr/bin/pip install --upgrade --upgrade-strategy=only-if-needed subunit2sql',
42 provider => openstack_pip, 42 # This checks the current installed subunit2sql version with pip list and
43 require => [ 43 # the latest version of subunit2sql on pypi with pip search and if they are
44 # different then we know we need to upgrade to reconcile the local version
45 # with the upstream version.
46 #
47 # We do this using this check here rather than a pip package resource so we
48 # can override pip's default upgrade strategy in order to avoid replacing
49 # deps we've preinstalled from system packages because they lack wheels on
50 # PyPI and must be otherwise rebuilt from sdist instead (specifically
51 # netifaces).
52 onlyif => '/bin/bash -c "test $(/usr/bin/pip list --format columns | sed -ne \'s/^subunit2sql\s\+\(.*\)$/\1/p\') != $(/usr/bin/pip search \'subunit2sql$\' | sed -ne \'s/^subunit2sql (\(.*\)).*$/\1/p\')"',
53 require => [
44 Class['pip'], 54 Class['pip'],
45 Package['python-mysqldb'], 55 Package['python-mysqldb'],
46 Package['python-psycopg2'], 56 Package['python-psycopg2'],
@@ -107,7 +117,7 @@ class subunit2sql (
107 Package['python-zmq'], 117 Package['python-zmq'],
108 Package['python-yaml'], 118 Package['python-yaml'],
109 Package['gear'], 119 Package['gear'],
110 Package['subunit2sql'], 120 Exec['install-subunit2sql-safely'],
111 Package['python-subunit'], 121 Package['python-subunit'],
112 Package['testtools'] 122 Package['testtools']
113 ], 123 ],
diff --git a/manifests/server.pp b/manifests/server.pp
index b418636..2916ccf 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -56,7 +56,7 @@ class subunit2sql::server (
56 exec { 'upgrade_subunit2sql_db': 56 exec { 'upgrade_subunit2sql_db':
57 command => '/usr/local/bin/run_migrations.sh', 57 command => '/usr/local/bin/run_migrations.sh',
58 require => File['/usr/local/bin/run_migrations.sh'], 58 require => File['/usr/local/bin/run_migrations.sh'],
59 subscribe => Package['subunit2sql'], 59 subscribe => Exec['install-subunit2sql-safely'],
60 refreshonly => true, 60 refreshonly => true,
61 timeout => 0, 61 timeout => 0,
62 } 62 }
diff --git a/manifests/worker.pp b/manifests/worker.pp
index 96b4bb9..c700daa 100644
--- a/manifests/worker.pp
+++ b/manifests/worker.pp
@@ -101,7 +101,7 @@ if ! defined(File['/var/log/subunit2sql']) {
101 hasrestart => true, 101 hasrestart => true,
102 subscribe => [ 102 subscribe => [
103 File["/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml"], 103 File["/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml"],
104 Package['subunit2sql'], 104 Exec['install-subunit2sql-safely'],
105 ], 105 ],
106 require => [ 106 require => [
107 File['/etc/subunit2sql'], 107 File['/etc/subunit2sql'],