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: I2f5d95d9688c48e97fbb9b8b11a23d4b6250e016 Closes-Bug: 1803451
This commit is contained in:
parent
7626a55b4a
commit
a42a2a8f3c
@ -42,6 +42,7 @@ from charmhelpers.core.hookenv import (
|
|||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
mkdir,
|
mkdir,
|
||||||
service_reload,
|
service_reload,
|
||||||
|
service_restart,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
@ -86,6 +87,7 @@ from neutron_api_utils import (
|
|||||||
check_local_db_actions_complete,
|
check_local_db_actions_complete,
|
||||||
pause_unit_helper,
|
pause_unit_helper,
|
||||||
resume_unit_helper,
|
resume_unit_helper,
|
||||||
|
remove_old_packages,
|
||||||
)
|
)
|
||||||
from neutron_api_context import (
|
from neutron_api_context import (
|
||||||
get_dns_domain,
|
get_dns_domain,
|
||||||
@ -295,9 +297,14 @@ def config_changed():
|
|||||||
apt_install(filter_installed_packages(
|
apt_install(filter_installed_packages(
|
||||||
determine_packages(config('openstack-origin'))),
|
determine_packages(config('openstack-origin'))),
|
||||||
fatal=True)
|
fatal=True)
|
||||||
|
packages_removed = remove_old_packages()
|
||||||
configure_https()
|
configure_https()
|
||||||
update_nrpe_config()
|
update_nrpe_config()
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
|
if packages_removed and not is_unit_paused_set():
|
||||||
|
log("Package purge detected, restarting services", "INFO")
|
||||||
|
for s in services():
|
||||||
|
service_restart(s)
|
||||||
for r_id in relation_ids('neutron-api'):
|
for r_id in relation_ids('neutron-api'):
|
||||||
neutron_api_relation_joined(rid=r_id)
|
neutron_api_relation_joined(rid=r_id)
|
||||||
for r_id in relation_ids('neutron-plugin-api'):
|
for r_id in relation_ids('neutron-plugin-api'):
|
||||||
|
@ -427,6 +427,18 @@ def determine_purge_packages():
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def remove_old_packages():
|
||||||
|
'''Purge any packages that need ot be removed.
|
||||||
|
|
||||||
|
:returns: bool Whether packages were removed.
|
||||||
|
'''
|
||||||
|
installed_packages = filter_missing_packages(determine_purge_packages())
|
||||||
|
if installed_packages:
|
||||||
|
apt_purge(installed_packages, fatal=True)
|
||||||
|
apt_autoremove(purge=True, fatal=True)
|
||||||
|
return bool(installed_packages)
|
||||||
|
|
||||||
|
|
||||||
def determine_ports():
|
def determine_ports():
|
||||||
'''Assemble a list of API ports for services we are managing'''
|
'''Assemble a list of API ports for services we are managing'''
|
||||||
ports = []
|
ports = []
|
||||||
@ -549,10 +561,7 @@ def do_openstack_upgrade(configs):
|
|||||||
options=dpkg_opts,
|
options=dpkg_opts,
|
||||||
fatal=True)
|
fatal=True)
|
||||||
|
|
||||||
installed_packages = filter_missing_packages(determine_purge_packages())
|
remove_old_packages()
|
||||||
if installed_packages:
|
|
||||||
apt_purge(installed_packages, fatal=True)
|
|
||||||
apt_autoremove(purge=True, fatal=True)
|
|
||||||
|
|
||||||
# set CONFIGS to load templates from new release
|
# set CONFIGS to load templates from new release
|
||||||
configs.set_release(openstack_release=new_os_rel)
|
configs.set_release(openstack_release=new_os_rel)
|
||||||
|
@ -91,6 +91,9 @@ TO_PATCH = [
|
|||||||
'get_relation_ip',
|
'get_relation_ip',
|
||||||
'update_dns_ha_resource_params',
|
'update_dns_ha_resource_params',
|
||||||
'is_nsg_logging_enabled',
|
'is_nsg_logging_enabled',
|
||||||
|
'remove_old_packages',
|
||||||
|
'services',
|
||||||
|
'service_restart',
|
||||||
]
|
]
|
||||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||||
|
|
||||||
@ -222,6 +225,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||||||
self._call_hook('config-changed')
|
self._call_hook('config-changed')
|
||||||
|
|
||||||
def test_config_changed_with_openstack_upgrade_action(self):
|
def test_config_changed_with_openstack_upgrade_action(self):
|
||||||
|
self.remove_old_packages.return_value = False
|
||||||
self.openstack_upgrade_available.return_value = True
|
self.openstack_upgrade_available.return_value = True
|
||||||
self.test_config.set('action-managed-upgrade', True)
|
self.test_config.set('action-managed-upgrade', True)
|
||||||
|
|
||||||
@ -229,6 +233,14 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||||||
|
|
||||||
self.assertFalse(self.do_openstack_upgrade.called)
|
self.assertFalse(self.do_openstack_upgrade.called)
|
||||||
|
|
||||||
|
def test_config_changed_with_purge(self):
|
||||||
|
self.remove_old_packages.return_value = True
|
||||||
|
self.services.return_value = ['neutron-server']
|
||||||
|
self.openstack_upgrade_available.return_value = False
|
||||||
|
self._call_hook('config-changed')
|
||||||
|
self.remove_old_packages.assert_called_once_with()
|
||||||
|
self.service_restart.assert_called_once_with('neutron-server')
|
||||||
|
|
||||||
def test_amqp_joined(self):
|
def test_amqp_joined(self):
|
||||||
self._call_hook('amqp-relation-joined')
|
self._call_hook('amqp-relation-joined')
|
||||||
self.relation_set.assert_called_with(
|
self.relation_set.assert_called_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user