upgrade-charm: filter previously installed packages

The upgrade-charm hook installs any new packages required for the
new charm version however this needs to be filtered against packages
that are already installed to ensure that any pending package
updates are not installed as a side effect of a charm upgrade.

Change-Id: Ie23b65fd97014134ba6f3d9004f18a4600cd2d5a
Closes-Bug: 1812982
This commit is contained in:
James Page 2019-01-23 17:05:00 +00:00
parent 64c15641fe
commit a070870967
2 changed files with 5 additions and 2 deletions

View File

@ -70,7 +70,8 @@ from charmhelpers.core.hookenv import (
from charmhelpers.fetch import (
apt_install,
apt_update
apt_update,
filter_installed_packages,
)
from charmhelpers.core.host import (
@ -524,7 +525,8 @@ def configure_https():
@hooks.hook('upgrade-charm')
@harden()
def upgrade_charm():
apt_install(determine_packages(), fatal=True)
apt_install(filter_installed_packages(determine_packages()),
fatal=True)
packages_removed = remove_old_packages()
for rel_id in relation_ids('amqp'):
amqp_joined(relation_id=rel_id)

View File

@ -74,6 +74,7 @@ TO_PATCH = [
# charmhelpers.core.host
'apt_install',
'apt_update',
'filter_installed_packages',
'service_reload',
'service_restart',
# charmhelpers.contrib.openstack.openstack_utils