Add separate OSD DB device support

Adds in three parts:

1. Create an API endpoint to create OSD DB volume groups on a device.
Passed through to the node via the same command pipeline as
creating/removing OSDs, and creates a volume group with a fixed name
(osd-db).

2. Adds API support for specifying whether or not to use this DB volume
group when creating a new OSD via the "ext_db" flag. Naming and sizing
is fixed for simplicity and based on Ceph recommendations (5% of OSD
size). The Zookeeper schema tracks the block device to use during
removal.

3. Adds CLI support for the new and modified API endpoints, as well as
displaying the block device and DB block device in the OSD list.

While I debated supporting adding a DB device to an existing OSD, in
practice this ended up being a very complex operation involving stopping
the OSD and setting some options, so this is not supported; this can be
specified during OSD creation only.

Closes #142
This commit is contained in:
2021-09-23 13:59:49 -04:00
parent df277edf1c
commit adc8a5a3bc
9 changed files with 491 additions and 23 deletions

View File

@ -180,20 +180,63 @@ def getClusterOSDList(zkhandler):
def getOSDInformation(zkhandler, osd_id):
# Get the devices
osd_device = zkhandler.read(('osd.device', osd_id))
osd_db_device = zkhandler.read(('osd.db_device', osd_id))
# Parse the stats data
osd_stats_raw = zkhandler.read(('osd.stats', osd_id))
osd_stats = dict(json.loads(osd_stats_raw))
osd_information = {
'id': osd_id,
'stats': osd_stats
'device': osd_device,
'db_device': osd_db_device,
'stats': osd_stats,
}
return osd_information
# OSD DB VG actions use the /cmd/ceph pipe
# These actions must occur on the specific node they reference
def add_osd_db_vg(zkhandler, node, device):
# Verify the target node exists
if not common.verifyNode(zkhandler, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
# Tell the cluster to create a new OSD for the host
add_osd_db_vg_string = 'db_vg_add {},{}'.format(node, device)
zkhandler.write([
('base.cmd.ceph', add_osd_db_vg_string)
])
# Wait 1/2 second for the cluster to get the message and start working
time.sleep(0.5)
# Acquire a read lock, so we get the return exclusively
with zkhandler.readlock('base.cmd.ceph'):
try:
result = zkhandler.read('base.cmd.ceph').split()[0]
if result == 'success-db_vg_add':
message = 'Created new OSD database VG at "{}" on node "{}".'.format(device, node)
success = True
else:
message = 'ERROR: Failed to create new OSD database VG; check node logs for details.'
success = False
except Exception:
message = 'ERROR: Command ignored by node.'
success = False
# Acquire a write lock to ensure things go smoothly
with zkhandler.writelock('base.cmd.ceph'):
time.sleep(0.5)
zkhandler.write([
('base.cmd.ceph', '')
])
return success, message
# OSD addition and removal uses the /cmd/ceph pipe
# These actions must occur on the specific node they reference
def add_osd(zkhandler, node, device, weight):
def add_osd(zkhandler, node, device, weight, ext_db_flag=False):
# Verify the target node exists
if not common.verifyNode(zkhandler, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
@ -204,7 +247,7 @@ def add_osd(zkhandler, node, device, weight):
return False, 'ERROR: Block device "{}" on node "{}" is used by OSD "{}"'.format(device, node, block_osd)
# Tell the cluster to create a new OSD for the host
add_osd_string = 'osd_add {},{},{}'.format(node, device, weight)
add_osd_string = 'osd_add {},{},{},{}'.format(node, device, weight, ext_db_flag)
zkhandler.write([
('base.cmd.ceph', add_osd_string)
])