Ensure that all packaged python deps are installed on upgrade

The referenced bug indicates that if the charm upgrades on a previous
py2 version of the charm then the upgrade fails due to a missing package
(in this python3-yaml).  This patchset ensures that the python3 versions
of the dependency packages are installed.

Change-Id: I8b07de3b2f950237518c0555db1288f9b2c0aabf
Closes-Bug: #1746650
This commit is contained in:
Alex Kavanagh 2019-11-29 15:25:26 +00:00
parent 6ad7badde5
commit db8ba4d938
3 changed files with 20 additions and 2 deletions

View File

@ -532,7 +532,7 @@ def relation_broken():
CONFIGS.write_all()
@hooks.hook('upgrade-charm')
@hooks.hook('upgrade-charm.real')
@harden()
def upgrade_charm():
apt_install(filter_installed_packages(determine_packages()),

View File

@ -1 +0,0 @@
nova_compute_hooks.py

18
hooks/upgrade-charm Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash -e
declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'dnspython')
check_and_install() {
pkg="${1}-${2}"
if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
apt-get -y install ${pkg}
fi
}
PYTHON="python3"
for dep in ${DEPS[@]}; do
check_and_install ${PYTHON} ${dep}
done
exec ./hooks/upgrade-charm.real

1
hooks/upgrade-charm.real Symbolic link
View File

@ -0,0 +1 @@
nova_compute_hooks.py