Add support for Storage hooks
This adds support for Juju's storage hooks by merging the config provided osd-devices with Juju storage provided osd-devices, in the same way that the existing Ceph charm handles them. In addition to providing support for ceph-osds via Juju storage, we provide support for multiple journal devices through Juju storage as well. We have to add a shim hook to ensure that Ceph is installed prior to storage hook invocation because storage attached at deploy time will execute hooks before the install hook Change-Id: Idad46e8f4cc32e09fbd64d29cd93745662e9f542
This commit is contained in:
parent
72b8ecade3
commit
7e2ef1d0ea
@ -10,7 +10,8 @@ options:
|
|||||||
The devices to format and set up as osd volumes.
|
The devices to format and set up as osd volumes.
|
||||||
|
|
||||||
These devices are the range of devices that will be checked for and
|
These devices are the range of devices that will be checked for and
|
||||||
used across all service units.
|
used across all service units, in addition to any volumes attached
|
||||||
|
via the --storage flag during deployment.
|
||||||
|
|
||||||
For ceph >= 0.56.6 these can also be directories instead of devices - the
|
For ceph >= 0.56.6 these can also be directories instead of devices - the
|
||||||
charm assumes anything not starting with /dev is a directory instead.
|
charm assumes anything not starting with /dev is a directory instead.
|
||||||
|
7
hooks/add-storage
Executable file
7
hooks/add-storage
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
|
||||||
|
# by default.
|
||||||
|
|
||||||
|
dpkg -l|grep 'python-apt ' || exit 0
|
||||||
|
|
||||||
|
exec ./hooks/storage.real
|
@ -31,6 +31,8 @@ from charmhelpers.core.hookenv import (
|
|||||||
UnregisteredHookError,
|
UnregisteredHookError,
|
||||||
service_name,
|
service_name,
|
||||||
status_set,
|
status_set,
|
||||||
|
storage_get,
|
||||||
|
storage_list,
|
||||||
)
|
)
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
umount,
|
umount,
|
||||||
@ -379,6 +381,7 @@ def config_changed():
|
|||||||
prepare_disks_and_activate()
|
prepare_disks_and_activate()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('storage.real')
|
||||||
def prepare_disks_and_activate():
|
def prepare_disks_and_activate():
|
||||||
osd_journal = get_journal_devices()
|
osd_journal = get_journal_devices()
|
||||||
check_overlap(osd_journal, set(get_devices()))
|
check_overlap(osd_journal, set(get_devices()))
|
||||||
@ -447,20 +450,31 @@ def reformat_osd():
|
|||||||
|
|
||||||
def get_devices():
|
def get_devices():
|
||||||
if config('osd-devices'):
|
if config('osd-devices'):
|
||||||
return [
|
devices = [
|
||||||
os.path.realpath(path)
|
os.path.realpath(path)
|
||||||
for path in config('osd-devices').split(' ')]
|
for path in config('osd-devices').split(' ')]
|
||||||
else:
|
else:
|
||||||
return []
|
devices = []
|
||||||
|
|
||||||
|
# List storage instances for the 'osd-devices'
|
||||||
|
# store declared for this charm too, and add
|
||||||
|
# their block device paths to the list.
|
||||||
|
storage_ids = storage_list('osd-devices')
|
||||||
|
devices.extend((storage_get('location', s) for s in storage_ids))
|
||||||
|
return devices
|
||||||
|
|
||||||
|
|
||||||
def get_journal_devices():
|
def get_journal_devices():
|
||||||
osd_journal = config('osd-journal')
|
if config('osd-journal'):
|
||||||
if not osd_journal:
|
devices = config('osd-journal')
|
||||||
return set()
|
devices = [l.strip() for l in config('osd-journal').split(' ')]
|
||||||
osd_journal = [l.strip() for l in config('osd-journal').split(' ')]
|
else:
|
||||||
osd_journal = set(filter(os.path.exists, osd_journal))
|
devices = []
|
||||||
return osd_journal
|
storage_ids = storage_list('osd-journals')
|
||||||
|
devices.extend((storage_get('location', s) for s in storage_ids))
|
||||||
|
devices = filter(os.path.exists, devices)
|
||||||
|
|
||||||
|
return set(devices)
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('mon-relation-changed',
|
@hooks.hook('mon-relation-changed',
|
||||||
|
1
hooks/osd-devices-storage-attached
Symbolic link
1
hooks/osd-devices-storage-attached
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
add-storage
|
1
hooks/osd-devices-storage-detaching
Symbolic link
1
hooks/osd-devices-storage-detaching
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
add-storage
|
1
hooks/storage.real
Symbolic link
1
hooks/storage.real
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
ceph_hooks.py
|
@ -19,3 +19,12 @@ description: |
|
|||||||
requires:
|
requires:
|
||||||
mon:
|
mon:
|
||||||
interface: ceph-osd
|
interface: ceph-osd
|
||||||
|
storage:
|
||||||
|
osd-devices:
|
||||||
|
type: block
|
||||||
|
multiple:
|
||||||
|
range: 0-
|
||||||
|
osd-journals:
|
||||||
|
type: block
|
||||||
|
multiple:
|
||||||
|
range: 0-
|
Loading…
Reference in New Issue
Block a user