From 7f15c2f5ce230ec3d1724d924a164e6a49b8584a Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 15 Oct 2018 16:39:52 +0100 Subject: [PATCH] py3: deal with subordinate dependencies Switch to marking non-leaf python-* packages as automatically installed so that they will be purged once the last remaining package that depends on them that was manually installed is removed. Force install of python3-nova-lxd for Rocky and above to ensure that py versions are matched with python3-nova. Change-Id: I79d528bfb7732490aa42da2158244350c03dfa59 Closes-Bug: 1797879 --- hooks/nova_compute_utils.py | 20 ++++++++++++++++++++ unit_tests/test_nova_compute_utils.py | 1 + 2 files changed, 21 insertions(+) diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index b6890783..c527eeea 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -34,6 +34,7 @@ from charmhelpers.fetch import ( apt_install, apt_purge, apt_autoremove, + apt_mark, filter_missing_packages, ) @@ -136,7 +137,12 @@ PY3_PACKAGES = [ PURGE_PACKAGES = [ 'python-nova', +] + +HELD_PACKAGES = [ 'python-memcache', + 'python-six', + 'python-psutil', ] VERSION_PACKAGE = 'nova-common' @@ -252,6 +258,7 @@ VIRT_TYPES = { 'lxd': ['nova-compute-lxd'], } + # Maps virt-type config to a libvirt URI. LIBVIRT_URIS = { 'kvm': 'qemu:///system', @@ -412,6 +419,8 @@ def determine_packages(): if cmp_release >= 'rocky': packages = [p for p in packages if not p.startswith('python-')] packages.extend(PY3_PACKAGES) + if virt_type == 'lxd': + packages.append('python3-nova-lxd') return packages @@ -424,6 +433,15 @@ def determine_purge_packages(): return [] +def determine_held_packages(): + '''Return a list of packages to mark as candidates for removal + for the current OS release''' + cmp_os_source = CompareOpenStackReleases(os_release('nova-common')) + if cmp_os_source >= 'rocky': + return HELD_PACKAGES + return [] + + def migration_enabled(): # XXX: confirm juju-core bool behavior is the same. return config('enable-live-migration') @@ -600,6 +618,8 @@ def do_openstack_upgrade(configs): determine_purge_packages() ) if installed_packages: + apt_mark(filter_missing_packages(determine_held_packages()), + 'auto') apt_purge(installed_packages, fatal=True) apt_autoremove(purge=True, fatal=True) diff --git a/unit_tests/test_nova_compute_utils.py b/unit_tests/test_nova_compute_utils.py index edc6eccb..c7825166 100644 --- a/unit_tests/test_nova_compute_utils.py +++ b/unit_tests/test_nova_compute_utils.py @@ -41,6 +41,7 @@ TO_PATCH = [ 'apt_update', 'apt_purge', 'apt_autoremove', + 'apt_mark', 'filter_missing_packages', 'config', 'os_release',