Merge "Ensure we only try to set sysctls outside of a container"
This commit is contained in:
commit
b4a468f9aa
@ -21,6 +21,7 @@ from charmhelpers.fetch import (
|
|||||||
apt_purge,
|
apt_purge,
|
||||||
)
|
)
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
|
is_container,
|
||||||
lsb_release,
|
lsb_release,
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.hahelpers.cluster import(
|
from charmhelpers.contrib.hahelpers.cluster import(
|
||||||
@ -124,8 +125,11 @@ def config_changed():
|
|||||||
|
|
||||||
sysctl_settings = config('sysctl')
|
sysctl_settings = config('sysctl')
|
||||||
if sysctl_settings:
|
if sysctl_settings:
|
||||||
create_sysctl(sysctl_settings,
|
if is_container():
|
||||||
'/etc/sysctl.d/50-quantum-gateway.conf')
|
log("Cannot create sysctls inside of a container", level=WARNING)
|
||||||
|
else:
|
||||||
|
create_sysctl(sysctl_settings,
|
||||||
|
'/etc/sysctl.d/50-quantum-gateway.conf')
|
||||||
|
|
||||||
if config('vendor-data'):
|
if config('vendor-data'):
|
||||||
write_vendordata(config('vendor-data'))
|
write_vendordata(config('vendor-data'))
|
||||||
|
@ -63,6 +63,7 @@ TO_PATCH = [
|
|||||||
'remove_legacy_nova_metadata',
|
'remove_legacy_nova_metadata',
|
||||||
'services',
|
'services',
|
||||||
'remove_old_packages',
|
'remove_old_packages',
|
||||||
|
'is_container',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ class TestQuantumHooks(CharmTestCase):
|
|||||||
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'}
|
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'}
|
||||||
# passthrough
|
# passthrough
|
||||||
self.b64decode.side_effect = lambda arg: arg
|
self.b64decode.side_effect = lambda arg: arg
|
||||||
|
self.is_container.return_value = False
|
||||||
hookenv.config.side_effect = self.test_config.get
|
hookenv.config.side_effect = self.test_config.get
|
||||||
hooks.hooks._config_save = False
|
hooks.hooks._config_save = False
|
||||||
|
|
||||||
@ -138,6 +140,28 @@ class TestQuantumHooks(CharmTestCase):
|
|||||||
'{foo : bar}',
|
'{foo : bar}',
|
||||||
'/etc/sysctl.d/50-quantum-gateway.conf')
|
'/etc/sysctl.d/50-quantum-gateway.conf')
|
||||||
|
|
||||||
|
def test_config_changed_in_container(self):
|
||||||
|
self.disable_nova_metadata.return_value = False
|
||||||
|
|
||||||
|
def mock_relids(rel):
|
||||||
|
return ['relid']
|
||||||
|
self.test_config.set(
|
||||||
|
'sysctl',
|
||||||
|
'{foo : bar}'
|
||||||
|
)
|
||||||
|
self.openstack_upgrade_available.return_value = True
|
||||||
|
self.valid_plugin.return_value = True
|
||||||
|
self.relation_ids.side_effect = mock_relids
|
||||||
|
self.is_container.return_value = True
|
||||||
|
_amqp_joined = self.patch('amqp_joined')
|
||||||
|
_amqp_nova_joined = self.patch('amqp_nova_joined')
|
||||||
|
self._call_hook('config-changed')
|
||||||
|
self.assertTrue(self.do_openstack_upgrade.called)
|
||||||
|
self.assertTrue(self.configure_ovs.called)
|
||||||
|
self.assertTrue(_amqp_joined.called)
|
||||||
|
self.assertTrue(_amqp_nova_joined.called)
|
||||||
|
self.create_sysctl.assert_not_called()
|
||||||
|
|
||||||
def test_config_changed_upgrade(self):
|
def test_config_changed_upgrade(self):
|
||||||
self.disable_nova_metadata.return_value = False
|
self.disable_nova_metadata.return_value = False
|
||||||
self.openstack_upgrade_available.return_value = True
|
self.openstack_upgrade_available.return_value = True
|
||||||
|
Loading…
Reference in New Issue
Block a user