Skip udev rule install in containers
Ensure that udev rules are not installed and reloaded when running in a container; this is not permitted and the udev rules are used for block devices, which are not supported within container based deployments. Change-Id: I9a580172fcbbf8cec63af7adccb0808915184658 Closes-Bug: 1776713
This commit is contained in:
parent
ec8bcd5f9d
commit
dd42690347
|
@ -55,6 +55,7 @@ from charmhelpers.core.host import (
|
|||
add_to_updatedb_prunepath,
|
||||
restart_on_change,
|
||||
write_file,
|
||||
is_container,
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
add_source,
|
||||
|
@ -225,6 +226,10 @@ def install_udev_rules():
|
|||
Install and reload udev rules for ceph-volume LV
|
||||
permissions
|
||||
"""
|
||||
if is_container():
|
||||
log('Skipping udev rule installation '
|
||||
'as unit is in a container', level=DEBUG)
|
||||
return
|
||||
for x in glob.glob('files/udev/*'):
|
||||
shutil.copy(x, '/lib/udev/rules.d')
|
||||
subprocess.check_call(['udevadm', 'control',
|
||||
|
|
|
@ -471,9 +471,11 @@ class CephHooksTestCase(unittest.TestCase):
|
|||
config.assert_called_with('availability_zone')
|
||||
environ.get.assert_called_with('JUJU_AVAILABILITY_ZONE')
|
||||
|
||||
@patch.object(ceph_hooks, 'is_container')
|
||||
@patch.object(ceph_hooks, 'subprocess')
|
||||
@patch.object(ceph_hooks, 'shutil')
|
||||
def test_install_udev_rules(self, shutil, subprocess):
|
||||
def test_install_udev_rules(self, shutil, subprocess, is_container):
|
||||
is_container.return_value = False
|
||||
ceph_hooks.install_udev_rules()
|
||||
shutil.copy.assert_called_once_with(
|
||||
'files/udev/95-charm-ceph-osd.rules',
|
||||
|
@ -483,6 +485,16 @@ class CephHooksTestCase(unittest.TestCase):
|
|||
['udevadm', 'control', '--reload-rules']
|
||||
)
|
||||
|
||||
@patch.object(ceph_hooks, 'is_container')
|
||||
@patch.object(ceph_hooks, 'subprocess')
|
||||
@patch.object(ceph_hooks, 'shutil')
|
||||
def test_install_udev_rules_container(self, shutil, subprocess,
|
||||
is_container):
|
||||
is_container.return_value = True
|
||||
ceph_hooks.install_udev_rules()
|
||||
shutil.copy.assert_not_called()
|
||||
subprocess.check_call.assert_not_called()
|
||||
|
||||
@patch.object(ceph_hooks, 'config')
|
||||
@patch.object(ceph_hooks, 'cmp_pkgrevno')
|
||||
def test_use_short_objects(self, mock_cmp_pkgrevno, mock_config):
|
||||
|
|
Loading…
Reference in New Issue