Send remote restart to neutron plugin post upgrade

When this principle charm performs and Openstack upgrade the
subordinates packages are also upgraded. The subordinate may need
to render new config for the new release so the charm now sends a
restart trigger to the subordinate

Change-Id: Ifd5dea4e67d09dc29bb0bba579fd8903fb64490a
Partial-Bug: 1571634
This commit is contained in:
Liam Young 2016-04-18 17:32:19 +00:00
parent 6a9e93567d
commit 68685d59df
2 changed files with 51 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/python
import platform
import sys
import uuid
from charmhelpers.core.hookenv import (
Hooks,
@ -118,6 +119,7 @@ def config_changed():
assert_charm_supports_ipv6()
global CONFIGS
send_remote_restart = False
if git_install_requested():
if config_value_changed('openstack-origin-git'):
status_set('maintenance', 'Running Git install')
@ -126,6 +128,7 @@ def config_changed():
if openstack_upgrade_available('nova-common'):
status_set('maintenance', 'Running openstack upgrade')
do_openstack_upgrade(CONFIGS)
send_remote_restart = True
sysctl_dict = config('sysctl')
if sysctl_dict:
@ -155,7 +158,7 @@ def config_changed():
zeromq_configuration_relation_joined(rid)
for rid in relation_ids('neutron-plugin'):
neutron_plugin_joined(rid)
neutron_plugin_joined(rid, remote_restart=send_remote_restart)
if is_relation_made("nrpe-external-master"):
update_nrpe_config()
@ -395,9 +398,14 @@ def update_nrpe_config():
@hooks.hook('neutron-plugin-relation-joined')
def neutron_plugin_joined(relid=None):
def neutron_plugin_joined(relid=None, remote_restart=False):
rel_settings = {
'hugepage_number': get_hugepage_number()
}
if remote_restart:
rel_settings['restart-trigger'] = str(uuid.uuid4())
relation_set(relation_id=relid,
hugepage_number=get_hugepage_number())
**rel_settings)
@hooks.hook('neutron-plugin-relation-changed')

View File

@ -70,6 +70,7 @@ TO_PATCH = [
'gethostname',
'create_sysctl',
'install_hugepages',
'uuid',
]
@ -118,11 +119,17 @@ class NovaComputeRelationsTests(CharmTestCase):
self.git_install.assert_called_with(projects_yaml)
self.assertTrue(self.execd_preinstall.called)
def test_config_changed_with_upgrade(self):
@patch.object(hooks, 'neutron_plugin_joined')
def test_config_changed_with_upgrade(self, neutron_plugin_joined):
self.git_install_requested.return_value = False
self.openstack_upgrade_available.return_value = True
def rel_ids(x):
return {'neutron-plugin': ['rid1']}.get(x, [])
self.relation_ids.side_effect = rel_ids
hooks.config_changed()
self.assertTrue(self.do_openstack_upgrade.called)
neutron_plugin_joined.assert_called_with('rid1', remote_restart=True)
@patch.object(hooks, 'git_install_requested')
def test_config_changed_with_openstack_upgrade_action(self, git_requested):
@ -508,3 +515,35 @@ class NovaComputeRelationsTests(CharmTestCase):
self.apt_purge.assert_called_with('nova-api-metadata',
fatal=True)
configs.write.assert_called_with('/etc/nova/nova.conf')
@patch.object(hooks, 'get_hugepage_number')
def test_neutron_plugin_joined_relid(self, get_hugepage_number):
get_hugepage_number.return_value = None
hooks.neutron_plugin_joined(relid='relid23')
self.relation_set.assert_called_with(
relation_id='relid23',
**{'hugepage_number': None}
)
@patch.object(hooks, 'get_hugepage_number')
def test_neutron_plugin_joined_huge(self, get_hugepage_number):
get_hugepage_number.return_value = 12
hooks.neutron_plugin_joined()
self.relation_set.assert_called_with(
relation_id=None,
**{'hugepage_number': 12}
)
@patch.object(hooks, 'get_hugepage_number')
def test_neutron_plugin_joined_remote_restart(self, get_hugepage_number):
get_hugepage_number.return_value = None
self.uuid.uuid4.return_value = 'e030b959-7207'
hooks.neutron_plugin_joined(remote_restart=True)
expect_rel_settings = {
'hugepage_number': None,
'restart-trigger': 'e030b959-7207',
}
self.relation_set.assert_called_with(
relation_id=None,
**expect_rel_settings
)