Add a config option to treat unusable disks as a non fatal error [james-page,r=tribaal]

This commit is contained in:
Christopher Glass 2014-09-12 14:08:22 +02:00
commit b2adb1a0c9
3 changed files with 29 additions and 8 deletions

View File

@ -48,6 +48,16 @@ options:
.
Specifying this option (any value) forces a reformat of any OSD devices
found which are not already mounted.
ignore-device-errors:
type: boolean
default: False
description: |
By default, the charm will raise errors if a whitelisted device is found,
but for some reason the charm is unable to initialize the device for use
by Ceph.
.
Setting this option to 'True' will result in the charm classifying such
problems as warnings only and will not result in a hook error.
ephemeral-unmount:
type: string
description: |

View File

@ -18,7 +18,7 @@ from charmhelpers.core.host import (
)
from charmhelpers.core.hookenv import (
log,
ERROR,
ERROR, WARNING
)
from charmhelpers.contrib.storage.linux.utils import (
zap_disk,
@ -307,14 +307,16 @@ def update_monfs():
pass
def osdize(dev, osd_format, osd_journal, reformat_osd=False):
def osdize(dev, osd_format, osd_journal, reformat_osd=False,
ignore_errors=False):
if dev.startswith('/dev'):
osdize_dev(dev, osd_format, osd_journal, reformat_osd)
osdize_dev(dev, osd_format, osd_journal, reformat_osd, ignore_errors)
else:
osdize_dir(dev)
def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False):
def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
ignore_errors=False):
if not os.path.exists(dev):
log('Path {} does not exist - bailing'.format(dev))
return
@ -349,7 +351,14 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False):
if reformat_osd:
zap_disk(dev)
subprocess.check_call(cmd)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
if ignore_errors:
log('Enable to initialize device: {}'.format(dev), WARNING)
else:
log('Enable to initialize device: {}'.format(dev), ERROR)
raise e
def osdize_dir(path):
@ -357,7 +366,7 @@ def osdize_dir(path):
log('Path {} is already configured as an OSD - bailing'.format(path))
return
if cmp_pkgrevno('ceph', '0.56.6.') < 0:
if cmp_pkgrevno('ceph', '0.56.6') < 0:
log('Unable to use directories for OSDs with ceph < 0.56.6',
level=ERROR)
raise

View File

@ -111,7 +111,8 @@ def config_changed():
emit_cephconf()
for dev in get_devices():
ceph.osdize(dev, config('osd-format'),
config('osd-journal'), config('osd-reformat'))
config('osd-journal'), config('osd-reformat'),
config('ignore-device-errors'))
ceph.start_osds(get_devices())
@ -172,7 +173,8 @@ def mon_relation():
ceph.import_osd_bootstrap_key(bootstrap_key)
for dev in get_devices():
ceph.osdize(dev, config('osd-format'),
config('osd-journal'), config('osd-reformat'))
config('osd-journal'), config('osd-reformat'),
config('ignore-device-errors'))
ceph.start_osds(get_devices())
else:
log('mon cluster has not yet provided conf')