ceph-volume: Install charm specific udev rules
Ensure that LV's created using the LVM layout implemented by this charm are correctly owned by the ceph user and group, ensuring that ceph-osd processes can start correctly at all times. Change-Id: I23ea51e3bffe7207f75782c5f34b796e9eed2c80 Closes-Bug: 1767087
This commit is contained in:
parent
4846c5654c
commit
35ad3de4f2
|
@ -0,0 +1,11 @@
|
|||
# OSD LV (ceph-osd charm layout)
|
||||
ACTION=="add", SUBSYSTEM=="block", \
|
||||
ENV{DEVTYPE}=="disk", \
|
||||
ENV{DM_LV_NAME}=="osd-*", \
|
||||
ENV{DM_VG_NAME}=="ceph-*", \
|
||||
OWNER:="ceph", GROUP:="ceph", MODE:="660"
|
||||
ACTION=="change", SUBSYSTEM=="block", \
|
||||
ENV{DEVTYPE}=="disk", \
|
||||
ENV{DM_LV_NAME}=="osd-*", \
|
||||
ENV{DM_VG_NAME}=="ceph-*", \
|
||||
OWNER="ceph", GROUP="ceph", MODE="660"
|
|
@ -19,6 +19,7 @@ import shutil
|
|||
import sys
|
||||
import tempfile
|
||||
import socket
|
||||
import subprocess
|
||||
import netifaces
|
||||
|
||||
sys.path.append('lib')
|
||||
|
@ -188,6 +189,17 @@ def install_apparmor_profile():
|
|||
service_restart('ceph-osd-all')
|
||||
|
||||
|
||||
def install_udev_rules():
|
||||
"""
|
||||
Install and reload udev rules for ceph-volume LV
|
||||
permissions
|
||||
"""
|
||||
for x in glob.glob('files/udev/*'):
|
||||
shutil.copy(x, '/lib/udev/rules.d')
|
||||
subprocess.check_call(['udevadm', 'control',
|
||||
'--reload-rules'])
|
||||
|
||||
|
||||
@hooks.hook('install.real')
|
||||
@harden()
|
||||
def install():
|
||||
|
@ -196,6 +208,7 @@ def install():
|
|||
apt_install(packages=ceph.determine_packages(), fatal=True)
|
||||
if config('autotune'):
|
||||
tune_network_adapters()
|
||||
install_udev_rules()
|
||||
|
||||
|
||||
def az_info():
|
||||
|
@ -503,6 +516,7 @@ def upgrade_charm():
|
|||
emit_cephconf()
|
||||
apt_install(packages=filter_installed_packages(ceph.determine_packages()),
|
||||
fatal=True)
|
||||
install_udev_rules()
|
||||
|
||||
|
||||
@hooks.hook('nrpe-external-master-relation-joined',
|
||||
|
|
|
@ -505,3 +505,15 @@ class CephHooksTestCase(unittest.TestCase):
|
|||
|
||||
config.assert_called_with('availability_zone')
|
||||
environ.get.assert_called_with('JUJU_AVAILABILITY_ZONE')
|
||||
|
||||
@patch.object(ceph_hooks, 'subprocess')
|
||||
@patch.object(ceph_hooks, 'shutil')
|
||||
def test_install_udev_rules(self, shutil, subprocess):
|
||||
ceph_hooks.install_udev_rules()
|
||||
shutil.copy.assert_called_once_with(
|
||||
'files/udev/95-charm-ceph-osd.rules',
|
||||
'/lib/udev/rules.d'
|
||||
)
|
||||
subprocess.check_call.assert_called_once_with(
|
||||
['udevadm', 'control', '--reload-rules']
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue