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

@ -3599,6 +3599,52 @@ class API_Storage_Ceph_Option(Resource):
api.add_resource(API_Storage_Ceph_Option, '/storage/ceph/option')
# /storage/ceph/osddb
class API_Storage_Ceph_OSDDB_Root(Resource):
@RequestParser([
{'name': 'node', 'required': True, 'helptext': "A valid node must be specified."},
{'name': 'device', 'required': True, 'helptext': "A valid device must be specified."},
])
@Authenticator
def post(self, reqargs):
"""
Add a Ceph OSD database volume group to the cluster
Note: This task may take up to 30s to complete and return
---
tags:
- storage / ceph
parameters:
- in: query
name: node
type: string
required: true
description: The PVC node to create the OSD DB volume group on
- in: query
name: device
type: string
required: true
description: The block device (e.g. "/dev/sdb", "/dev/disk/by-path/...", etc.) to create the OSD DB volume group on
responses:
200:
description: OK
schema:
type: object
id: Message
400:
description: Bad request
schema:
type: object
id: Message
"""
return api_helper.ceph_osd_db_vg_add(
reqargs.get('node', None),
reqargs.get('device', None)
)
api.add_resource(API_Storage_Ceph_OSDDB_Root, '/storage/ceph/osddb')
# /storage/ceph/osd
class API_Storage_Ceph_OSD_Root(Resource):
@RequestParser([
@ -3619,6 +3665,12 @@ class API_Storage_Ceph_OSD_Root(Resource):
id:
type: string (containing integer)
description: The Ceph ID of the OSD
device:
type: string
description: The OSD data block device
db_device:
type: string
description: The OSD database/WAL block device (logical volume); empty if not applicable
stats:
type: object
properties:
@ -3698,6 +3750,7 @@ class API_Storage_Ceph_OSD_Root(Resource):
{'name': 'node', 'required': True, 'helptext': "A valid node must be specified."},
{'name': 'device', 'required': True, 'helptext': "A valid device must be specified."},
{'name': 'weight', 'required': True, 'helptext': "An OSD weight must be specified."},
{'name': 'ext_db', 'required': False, 'helptext': "Whether to use an external OSD DB LV device."},
])
@Authenticator
def post(self, reqargs):
@ -3723,6 +3776,11 @@ class API_Storage_Ceph_OSD_Root(Resource):
type: number
required: true
description: The Ceph CRUSH weight for the OSD
- in: query
name: ext_db
type: boolean
required: false
description: Whether to use an external OSD DB LV device
responses:
200:
description: OK
@ -3738,7 +3796,8 @@ class API_Storage_Ceph_OSD_Root(Resource):
return api_helper.ceph_osd_add(
reqargs.get('node', None),
reqargs.get('device', None),
reqargs.get('weight', None)
reqargs.get('weight', None),
reqargs.get('ext_db', False),
)

View File

@ -1274,11 +1274,29 @@ def ceph_osd_state(zkhandler, osd):
@ZKConnection(config)
def ceph_osd_add(zkhandler, node, device, weight):
def ceph_osd_db_vg_add(zkhandler, node, device):
"""
Add a Ceph OSD database VG to the PVC Ceph storage cluster.
"""
retflag, retdata = pvc_ceph.add_osd_db_vg(zkhandler, node, device)
if retflag:
retcode = 200
else:
retcode = 400
output = {
'message': retdata.replace('\"', '\'')
}
return output, retcode
@ZKConnection(config)
def ceph_osd_add(zkhandler, node, device, weight, ext_db_flag=False):
"""
Add a Ceph OSD to the PVC Ceph storage cluster.
"""
retflag, retdata = pvc_ceph.add_osd(zkhandler, node, device, weight)
retflag, retdata = pvc_ceph.add_osd(zkhandler, node, device, weight, ext_db_flag)
if retflag:
retcode = 200