From c158d7432b48cd0a56ec1cf8503c74c4df39e493 Mon Sep 17 00:00:00 2001 From: Chris MacNaughton Date: Wed, 7 Nov 2018 17:17:31 +0100 Subject: [PATCH] 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/ --- lib/ceph/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ceph/utils.py b/lib/ceph/utils.py index 2ef48abe..07f96a67 100644 --- a/lib/ceph/utils.py +++ b/lib/ceph/utils.py @@ -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