summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Young <liam.young@canonical.com>2018-11-15 12:52:44 +0000
committerLiam Young <liam.young@canonical.com>2018-11-15 12:52:44 +0000
commitc88155d17acdb4f249eae778470578287668ee32 (patch)
treefc494b2cc24e570e0fdfe273519f25889512b9d4
parent3bcf3dcdbb6c6d296728a5920b3423e80fb02b34 (diff)
Purge old packages on upgrade-charmHEADmaster
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
Notes
Notes (review): Verified+1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: James Page <james.page@canonical.com> Workflow+1: James Page <james.page@canonical.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 15 Nov 2018 14:29:25 +0000 Reviewed-on: https://review.openstack.org/618153 Project: openstack/charm-nova-cloud-controller Branch: refs/heads/master
-rwxr-xr-xhooks/nova_cc_hooks.py6
-rw-r--r--hooks/nova_cc_utils.py19
2 files changed, 20 insertions, 5 deletions
diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py
index 5b94bab..5ac455f 100755
--- a/hooks/nova_cc_hooks.py
+++ b/hooks/nova_cc_hooks.py
@@ -951,6 +951,12 @@ def upgrade_charm():
951 ch_fetch.apt_install( 951 ch_fetch.apt_install(
952 ch_fetch.filter_installed_packages( 952 ch_fetch.filter_installed_packages(
953 ncc_utils.determine_packages()), fatal=True) 953 ncc_utils.determine_packages()), fatal=True)
954 packages_removed = ncc_utils.remove_old_packages()
955 if packages_removed:
956 hookenv.log("Package purge detected, restarting services", "INFO")
957 for s in ncc_utils.services():
958 ch_host.service_restart(s)
959
954 for r_id in hookenv.relation_ids('amqp'): 960 for r_id in hookenv.relation_ids('amqp'):
955 amqp_joined(relation_id=r_id) 961 amqp_joined(relation_id=r_id)
956 for r_id in hookenv.relation_ids('identity-service'): 962 for r_id in hookenv.relation_ids('identity-service'):
diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py
index eb5f641..c2fad78 100644
--- a/hooks/nova_cc_utils.py
+++ b/hooks/nova_cc_utils.py
@@ -395,6 +395,19 @@ def determine_purge_packages():
395 return [] 395 return []
396 396
397 397
398def remove_old_packages():
399 '''Purge any packages that need ot be removed.
400
401 :returns: bool Whether packages were removed.
402 '''
403 installed_packages = ch_fetch.filter_missing_packages(
404 determine_purge_packages())
405 if installed_packages:
406 ch_fetch.apt_purge(installed_packages, fatal=True)
407 ch_fetch.apt_autoremove(purge=True, fatal=True)
408 return bool(installed_packages)
409
410
398def save_script_rc(): 411def save_script_rc():
399 env_vars = { 412 env_vars = {
400 'OPENSTACK_PORT_MCASTPORT': hookenv.config('ha-mcastport'), 413 'OPENSTACK_PORT_MCASTPORT': hookenv.config('ha-mcastport'),
@@ -547,11 +560,7 @@ def _do_openstack_upgrade(new_src):
547 ch_utils.reset_os_release() 560 ch_utils.reset_os_release()
548 ch_fetch.apt_install(determine_packages(), fatal=True) 561 ch_fetch.apt_install(determine_packages(), fatal=True)
549 562
550 installed_pkgs = ch_fetch.filter_missing_packages( 563 remove_old_packages()
551 determine_purge_packages())
552 if installed_pkgs:
553 ch_fetch.apt_purge(installed_pkgs, fatal=True)
554 ch_fetch.apt_autoremove(purge=True, fatal=True)
555 564
556 disable_policy_rcd() 565 disable_policy_rcd()
557 566