Implement configurable replcfg (client-side)

Implements administrator-selectable replication configurations for new
pools in PVC clusters, overriding the default of copies=3,mincopies=2.
This commit is contained in:
Joshua Boniface 2019-08-23 14:12:15 -04:00
parent 0bacae21d7
commit 3b7c1adf71
4 changed files with 23 additions and 7 deletions

View File

@ -870,12 +870,12 @@ def ceph_pool_list(limit=None):
pvc_common.stopZKConnection(zk_conn) pvc_common.stopZKConnection(zk_conn)
return flask.jsonify(retdata), retcode return flask.jsonify(retdata), retcode
def ceph_pool_add(name, pgs): def ceph_pool_add(name, pgs, replcfg):
""" """
Add a Ceph RBD pool to the PVC Ceph storage cluster. Add a Ceph RBD pool to the PVC Ceph storage cluster.
""" """
zk_conn = pvc_common.startZKConnection(config['coordinators']) zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_ceph.add_pool(zk_conn, name, pgs) retflag, retdata = pvc_ceph.add_pool(zk_conn, name, pgs, replcfg)
if retflag: if retflag:
retcode = 200 retcode = 200
else: else:

View File

@ -755,6 +755,13 @@ def api_ceph_pool_root():
# We default to a very small number; DOCUMENT THIS # We default to a very small number; DOCUMENT THIS
pgs = 128 pgs = 128
# Get replication configuration
if 'replcfg' in flask.request.values:
replcfg = flask.request.values['replcfg']
else:
# We default to copies=3,mincopies=2
replcfg = 'copies=3,mincopies=2'
return pvcapi.ceph_pool_add(pool, pgs) return pvcapi.ceph_pool_add(pool, pgs)
@api.route('/api/v1/storage/ceph/pool/<pool>', methods=['GET', 'DELETE']) @api.route('/api/v1/storage/ceph/pool/<pool>', methods=['GET', 'DELETE'])

View File

@ -1380,13 +1380,22 @@ def ceph_pool():
@click.argument( @click.argument(
'pgs' 'pgs'
) )
def ceph_pool_add(name, pgs): @click.option(
'--replcfg', 'replcfg',
default='copies=3,mincopies=2', show_default=True, required=False,
help="""
The replication configuration, specifying both a "copies" and "mincopies" value, separated by a
comma, e.g. "copies=3,mincopies=2". The "copies" value specifies the total number of replicas and should not exceed the total number of nodes; the "mincopies" value specifies the minimum number of available copies to allow writes. For additional details please see the Cluster Architecture documentation.
"""
)
def ceph_pool_add(name, pgs, replcfg):
""" """
Add a new Ceph RBD pool with name NAME and PGS placement groups. Add a new Ceph RBD pool with name NAME and PGS placement groups.
""" """
zk_conn = pvc_common.startZKConnection(zk_host) zk_conn = pvc_common.startZKConnection(zk_host)
retcode, retmsg = pvc_ceph.add_pool(zk_conn, name, pgs) retcode, retmsg = pvc_ceph.add_pool(zk_conn, name, pgs, replcfg)
cleanup(retcode, retmsg, zk_conn) cleanup(retcode, retmsg, zk_conn)
############################################################################### ###############################################################################

View File

@ -658,9 +658,9 @@ def getPoolInformation(zk_conn, pool):
} }
return pool_information return pool_information
def add_pool(zk_conn, name, pgs): def add_pool(zk_conn, name, pgs, replcfg):
# Tell the cluster to create a new pool # Tell the cluster to create a new pool
add_pool_string = 'pool_add {},{}'.format(name, pgs) add_pool_string = 'pool_add {},{},{}'.format(name, pgs, replcfg)
zkhandler.writedata(zk_conn, {'/cmd/ceph': add_pool_string}) zkhandler.writedata(zk_conn, {'/cmd/ceph': add_pool_string})
# Wait 1/2 second for the cluster to get the message and start working # Wait 1/2 second for the cluster to get the message and start working
time.sleep(0.5) time.sleep(0.5)
@ -670,7 +670,7 @@ def add_pool(zk_conn, name, pgs):
try: try:
result = zkhandler.readdata(zk_conn, '/cmd/ceph').split()[0] result = zkhandler.readdata(zk_conn, '/cmd/ceph').split()[0]
if result == 'success-pool_add': if result == 'success-pool_add':
message = 'Created new RBD pool "{}" with "{}" PGs.'.format(name, pgs) message = 'Created new RBD pool "{}" with "{}" PGs and replication configuration {}.'.format(name, pgs, replcfg)
success = True success = True
else: else:
message = 'ERROR: Failed to create new pool; check node logs for details.' message = 'ERROR: Failed to create new pool; check node logs for details.'