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 ( require => Class['pip'], } - package { 'subunit2sql': - ensure => latest, - provider => openstack_pip, - require => [ + exec { 'install-subunit2sql-safely': + command => '/usr/bin/pip install --upgrade --upgrade-strategy=only-if-needed subunit2sql', + # This checks the current installed subunit2sql version with pip list and + # the latest version of subunit2sql on pypi with pip search and if they are + # different then we know we need to upgrade to reconcile the local version + # with the upstream version. + # + # We do this using this check here rather than a pip package resource so we + # can override pip's default upgrade strategy in order to avoid replacing + # deps we've preinstalled from system packages because they lack wheels on + # PyPI and must be otherwise rebuilt from sdist instead (specifically + # netifaces). + 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\')"', + require => [ Class['pip'], Package['python-mysqldb'], Package['python-psycopg2'], @@ -107,7 +117,7 @@ class subunit2sql ( Package['python-zmq'], Package['python-yaml'], Package['gear'], - Package['subunit2sql'], + Exec['install-subunit2sql-safely'], Package['python-subunit'], Package['testtools'] ], 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 ( exec { 'upgrade_subunit2sql_db': command => '/usr/local/bin/run_migrations.sh', require => File['/usr/local/bin/run_migrations.sh'], - subscribe => Package['subunit2sql'], + subscribe => Exec['install-subunit2sql-safely'], refreshonly => true, timeout => 0, } 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']) { hasrestart => true, subscribe => [ File["/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml"], - Package['subunit2sql'], + Exec['install-subunit2sql-safely'], ], require => [ File['/etc/subunit2sql'],