Purge old packages on upgrade-charm
On charm upgrade the charm may switch to py3 packages. If so, ensure the old py2 packages are purged. If the purge occurs then restart services. Change-Id: I984a227b3fe12a0086c926ae69c27d6e4d9741d3 Closes-Bug: 1803451
This commit is contained in:
parent
3bcf3dcdbb
commit
c88155d17a
|
@ -951,6 +951,12 @@ def upgrade_charm():
|
|||
ch_fetch.apt_install(
|
||||
ch_fetch.filter_installed_packages(
|
||||
ncc_utils.determine_packages()), fatal=True)
|
||||
packages_removed = ncc_utils.remove_old_packages()
|
||||
if packages_removed:
|
||||
hookenv.log("Package purge detected, restarting services", "INFO")
|
||||
for s in ncc_utils.services():
|
||||
ch_host.service_restart(s)
|
||||
|
||||
for r_id in hookenv.relation_ids('amqp'):
|
||||
amqp_joined(relation_id=r_id)
|
||||
for r_id in hookenv.relation_ids('identity-service'):
|
||||
|
|
|
@ -395,6 +395,19 @@ def determine_purge_packages():
|
|||
return []
|
||||
|
||||
|
||||
def remove_old_packages():
|
||||
'''Purge any packages that need ot be removed.
|
||||
|
||||
:returns: bool Whether packages were removed.
|
||||
'''
|
||||
installed_packages = ch_fetch.filter_missing_packages(
|
||||
determine_purge_packages())
|
||||
if installed_packages:
|
||||
ch_fetch.apt_purge(installed_packages, fatal=True)
|
||||
ch_fetch.apt_autoremove(purge=True, fatal=True)
|
||||
return bool(installed_packages)
|
||||
|
||||
|
||||
def save_script_rc():
|
||||
env_vars = {
|
||||
'OPENSTACK_PORT_MCASTPORT': hookenv.config('ha-mcastport'),
|
||||
|
@ -547,11 +560,7 @@ def _do_openstack_upgrade(new_src):
|
|||
ch_utils.reset_os_release()
|
||||
ch_fetch.apt_install(determine_packages(), fatal=True)
|
||||
|
||||
installed_pkgs = ch_fetch.filter_missing_packages(
|
||||
determine_purge_packages())
|
||||
if installed_pkgs:
|
||||
ch_fetch.apt_purge(installed_pkgs, fatal=True)
|
||||
ch_fetch.apt_autoremove(purge=True, fatal=True)
|
||||
remove_old_packages()
|
||||
|
||||
disable_policy_rcd()
|
||||
|
||||
|
|
Loading…
Reference in New Issue