Add directories to osd-devices as well

Tracking directory backed OSDs in the kv store allows
us to bootstrap further relations based on bootstrapped
OSD counts.

Change-Id: I1abd767d15c204845d9909d9c7ee9414dbe87a5c
Closes-Bug: #1802134
Depends-On: https://review.openstack.org/#/c/616230/
This commit is contained in:
Chris MacNaughton 2018-11-07 17:17:31 +01:00
parent f2b1b942f7
commit c158d7432b
1 changed files with 15 additions and 0 deletions

View File

@ -1876,6 +1876,14 @@ def osdize_dir(path, encrypt=False, bluestore=False):
:param encrypt: bool. Should the OSD directory be encrypted at rest
:returns: None
"""
db = kv()
osd_devices = db.get('osd-devices', [])
if path in osd_devices:
log('Device {} already processed by charm,'
' skipping'.format(path))
return
if os.path.exists(os.path.join(path, 'upstart')):
log('Path {} is already configured as an OSD - bailing'.format(path))
return
@ -1906,6 +1914,13 @@ def osdize_dir(path, encrypt=False, bluestore=False):
log("osdize dir cmd: {}".format(cmd))
subprocess.check_call(cmd)
# NOTE: Record processing of device only on success to ensure that
# the charm only tries to initialize a device of OSD usage
# once during its lifetime.
osd_devices.append(path)
db.set('osd-devices', osd_devices)
db.flush()
def filesystem_mounted(fs):
return subprocess.call(['grep', '-wqs', fs, '/proc/mounts']) == 0