Restart nova-compute if packages have been purged.
If packages have been purged off the system then trigger a restart of nova-compute by sending a restart trigger via the neutron-plugin relation. Change-Id: I5c8272d8c83b5112b6d8cebbbf3c485b87b7ef31 Closes-Bug: 1802304
This commit is contained in:
parent
880e0441c5
commit
71b5196b5b
|
@ -15,6 +15,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import uuid
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
@ -105,7 +106,11 @@ def config_changed():
|
||||||
|
|
||||||
# NOTE(jamespage): purge any packages as a result of py3 switch
|
# NOTE(jamespage): purge any packages as a result of py3 switch
|
||||||
# at rocky.
|
# at rocky.
|
||||||
purge_packages(determine_purge_packages())
|
packages_to_purge = determine_purge_packages()
|
||||||
|
request_nova_compute_restart = False
|
||||||
|
if packages_to_purge:
|
||||||
|
purge_packages(packages_to_purge)
|
||||||
|
request_nova_compute_restart = True
|
||||||
|
|
||||||
configure_ovs()
|
configure_ovs()
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
|
@ -113,7 +118,9 @@ def config_changed():
|
||||||
# to allow us to enable boot time execution of init script
|
# to allow us to enable boot time execution of init script
|
||||||
configure_sriov()
|
configure_sriov()
|
||||||
for rid in relation_ids('neutron-plugin'):
|
for rid in relation_ids('neutron-plugin'):
|
||||||
neutron_plugin_joined(relation_id=rid)
|
neutron_plugin_joined(
|
||||||
|
relation_id=rid,
|
||||||
|
request_restart=request_nova_compute_restart)
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('neutron-plugin-api-relation-changed')
|
@hooks.hook('neutron-plugin-api-relation-changed')
|
||||||
|
@ -131,7 +138,7 @@ def neutron_plugin_api_changed():
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('neutron-plugin-relation-joined')
|
@hooks.hook('neutron-plugin-relation-joined')
|
||||||
def neutron_plugin_joined(relation_id=None):
|
def neutron_plugin_joined(relation_id=None, request_restart=False):
|
||||||
if enable_local_dhcp():
|
if enable_local_dhcp():
|
||||||
install_packages()
|
install_packages()
|
||||||
else:
|
else:
|
||||||
|
@ -146,6 +153,8 @@ def neutron_plugin_joined(relation_id=None):
|
||||||
rel_data = {
|
rel_data = {
|
||||||
'metadata-shared-secret': secret,
|
'metadata-shared-secret': secret,
|
||||||
}
|
}
|
||||||
|
if request_restart:
|
||||||
|
rel_data['restart-nonce'] = str(uuid.uuid4())
|
||||||
relation_set(relation_id=relation_id, **rel_data)
|
relation_set(relation_id=relation_id, **rel_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,13 +109,18 @@ class NeutronOVSHooksTests(CharmTestCase):
|
||||||
self.assertTrue(self.CONFIGS.write_all.called)
|
self.assertTrue(self.CONFIGS.write_all.called)
|
||||||
self.configure_ovs.assert_called_with()
|
self.configure_ovs.assert_called_with()
|
||||||
|
|
||||||
def test_config_changed_rocky_upgrade(self):
|
@patch.object(hooks, 'neutron_plugin_joined')
|
||||||
|
def test_config_changed_rocky_upgrade(self, _plugin_joined):
|
||||||
self.determine_purge_packages.return_value = ['python-neutron']
|
self.determine_purge_packages.return_value = ['python-neutron']
|
||||||
|
self.relation_ids.return_value = ['neutron-plugin:42']
|
||||||
self._call_hook('config-changed')
|
self._call_hook('config-changed')
|
||||||
self.install_packages.assert_called_with()
|
self.install_packages.assert_called_with()
|
||||||
self.assertTrue(self.CONFIGS.write_all.called)
|
self.assertTrue(self.CONFIGS.write_all.called)
|
||||||
self.configure_ovs.assert_called_with()
|
self.configure_ovs.assert_called_with()
|
||||||
self.purge_packages.assert_called_with(['python-neutron'])
|
self.purge_packages.assert_called_with(['python-neutron'])
|
||||||
|
_plugin_joined.assert_called_with(
|
||||||
|
relation_id='neutron-plugin:42',
|
||||||
|
request_restart=True)
|
||||||
|
|
||||||
@patch.object(hooks, 'neutron_plugin_joined')
|
@patch.object(hooks, 'neutron_plugin_joined')
|
||||||
def test_neutron_plugin_api(self, _plugin_joined):
|
def test_neutron_plugin_api(self, _plugin_joined):
|
||||||
|
|
Loading…
Reference in New Issue