diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 620a73cf..f7433d1c 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -49,6 +49,7 @@ from charmhelpers.core.host import ( service_stop, write_file, umount, + is_container, ) from charmhelpers.fetch import ( apt_install, @@ -181,7 +182,7 @@ def config_changed(): send_remote_restart = True sysctl_settings = config('sysctl') - if sysctl_settings: + if sysctl_settings and not is_container(): create_sysctl(sysctl_settings, '/etc/sysctl.d/50-nova-compute.conf') remove_libvirt_network('default') diff --git a/unit_tests/test_nova_compute_hooks.py b/unit_tests/test_nova_compute_hooks.py index 1f46f974..efa92a69 100644 --- a/unit_tests/test_nova_compute_hooks.py +++ b/unit_tests/test_nova_compute_hooks.py @@ -54,6 +54,7 @@ TO_PATCH = [ 'filter_installed_packages', 'restart_on_change', 'service_restart', + 'is_container', # charmhelpers.contrib.openstack.utils 'configure_installation_source', 'openstack_upgrade_available', @@ -110,6 +111,7 @@ class NovaComputeRelationsTests(CharmTestCase): MagicMock(side_effect=lambda pkgs: pkgs) self.gethostname.return_value = 'testserver' self.get_relation_ip.return_value = '10.0.0.50' + self.is_container.return_value = False def test_install_hook(self): repo = 'cloud:precise-grizzly' @@ -222,6 +224,17 @@ class NovaComputeRelationsTests(CharmTestCase): '{foo : bar}', '/etc/sysctl.d/50-nova-compute.conf') + @patch.object(hooks, 'compute_joined') + def test_config_changed_with_sysctl_in_container(self, compute_joined): + self.migration_enabled.return_value = False + self.is_container.return_value = True + self.test_config.set( + 'sysctl', + '{foo : bar}' + ) + hooks.config_changed() + self.create_sysctl.assert_not_called() + @patch.object(hooks, 'compute_joined') def test_config_changed_no_nrpe(self, compute_joined): self.openstack_upgrade_available.return_value = False