Merge "Refine command ceph-mon-modify for all nodes support"

This commit is contained in:
Zuul 2019-07-31 18:34:46 +00:00 committed by Gerrit Code Review
commit b248dd1638
3 changed files with 80 additions and 55 deletions

View File

@ -333,8 +333,9 @@ class CephMonController(rest.RestController):
if is_ceph_mon_gib_changed:
_check_ceph_mon(cephmon.as_dict(), rpc_cephmon.as_dict())
controller_fs_utils._check_controller_fs(
ceph_mon_gib_new=cephmon.ceph_mon_gib)
controller_fs_utils._check_ceph_mon_growth(
cephmon.ceph_mon_gib)
utils.check_all_ceph_mon_growth(cephmon.ceph_mon_gib)
for field in objects.ceph_mon.fields:
if rpc_cephmon[field] != cephmon.as_dict()[field]:
@ -455,20 +456,20 @@ def _create(ceph_mon):
ceph_mon = _set_defaults(ceph_mon)
_check_ceph_mon(ceph_mon)
controller_fs_utils._check_controller_fs(
ceph_mon_gib_new=ceph_mon['ceph_mon_gib'])
pecan.request.rpcapi.reserve_ip_for_first_storage_node(
pecan.request.context)
# Size of ceph-mon logical volume must be the same for all
# monitors so we get the size from any or use default.
ceph_mons = pecan.request.dbapi.ceph_mon_get_list()
if ceph_mons:
ceph_mon['ceph_mon_gib'] = ceph_mons[0]['ceph_mon_gib']
_check_ceph_mon(ceph_mon)
controller_fs_utils._check_ceph_mon_growth(ceph_mon['ceph_mon_gib'])
utils.check_all_ceph_mon_growth(ceph_mon['ceph_mon_gib'], chost)
pecan.request.rpcapi.reserve_ip_for_first_storage_node(
pecan.request.context)
# In case we add the monitor on a worker node, the state
# and task must be set properly.
if chost.personality == constants.WORKER:

View File

@ -429,59 +429,26 @@ def _get_controller_cgtsvg_limit():
return cgtsvg_max_free_GiB
def _check_controller_fs(controller_fs_new=None,
ceph_mon_gib_new=None,
cgtsvg_growth_gib=None,
controller_fs_list=None):
ceph_mons = pecan.request.dbapi.ceph_mon_get_list()
if not controller_fs_list:
controller_fs_list = pecan.request.dbapi.controller_fs_get_list()
if not ceph_mon_gib_new:
if ceph_mons:
ceph_mon_gib_new = ceph_mons[0].ceph_mon_gib
else:
ceph_mon_gib_new = 0
else:
if ceph_mons:
cgtsvg_growth_gib = ceph_mon_gib_new - ceph_mons[0].ceph_mon_gib
else:
cgtsvg_growth_gib = ceph_mon_gib_new
def _check_ceph_mon_growth(ceph_mon_gib):
""" Check growth of ceph_mon in controller.
There is additional items to check for controller_fs compared with
check_node_ceph_mon_growth().
"""
controller_fs_list = pecan.request.dbapi.controller_fs_get_list()
cgtsvg_max_free_GiB = _get_controller_cgtsvg_limit()
LOG.info("_check_controller_fs ceph_mon_gib_new = %s" % ceph_mon_gib_new)
LOG.info("_check_controller_fs cgtsvg_growth_gib = %s" % cgtsvg_growth_gib)
LOG.info("_check_controller_fs cgtsvg_max_free_GiB = %s" % cgtsvg_max_free_GiB)
LOG.info("_check_ceph_mon_growth ceph_mon_gib = %s, "
"cgtsvg_max_free_GiB = %s" % (ceph_mon_gib, cgtsvg_max_free_GiB))
_check_relative_controller_fs(controller_fs_new, controller_fs_list)
_check_relative_controller_fs(None, controller_fs_list)
rootfs_configured_size_GiB = \
_total_size_controller_fs(controller_fs_new,
controller_fs_list) + ceph_mon_gib_new
LOG.info("_check_controller_fs rootfs_configured_size_GiB = %s" %
_total_size_controller_fs(None, controller_fs_list) + ceph_mon_gib
LOG.info("_check_ceph_mon_growth rootfs_configured_size_GiB = %s" %
rootfs_configured_size_GiB)
if cgtsvg_growth_gib and (cgtsvg_growth_gib > cgtsvg_max_free_GiB):
if ceph_mon_gib_new:
msg = _(
"Total target growth size %s GiB for database "
"(doubled for upgrades), glance, "
"scratch, backup, extension and ceph-mon exceeds "
"growth limit of %s GiB." %
(cgtsvg_growth_gib, cgtsvg_max_free_GiB)
)
else:
msg = _(
"Total target growth size %s GiB for database "
"(doubled for upgrades), glance, scratch, "
"backup and extension exceeds growth limit of %s GiB." %
(cgtsvg_growth_gib, cgtsvg_max_free_GiB)
)
raise wsme.exc.ClientSideError(msg)
utils.check_node_ceph_mon_growth(None, ceph_mon_gib, cgtsvg_max_free_GiB)
def _check_controller_multi_fs_data(context, controller_fs_list_new):

View File

@ -473,6 +473,63 @@ def get_node_cgtsvg_limit(host):
return cgtsvg_max_free_gib
def check_node_ceph_mon_growth(host, ceph_mon_gib, cgtsvg_max_free_gib):
""" Check node for ceph_mon growth, include controller/worker/storage node,
if check failed, raise error with msg.
"""
if host is not None:
ceph_mon = pecan.request.dbapi.ceph_mon_get_by_ihost(host.uuid)
hostname = host.hostname
else:
ceph_mon = pecan.request.dbapi.ceph_mon_get_list()
hostname = "controller"
if ceph_mon:
cgtsvg_growth_gib = ceph_mon_gib - ceph_mon[0].ceph_mon_gib
else:
cgtsvg_growth_gib = ceph_mon_gib
LOG.info("check_node_ceph_mon_growth hostname: %s, ceph_mon_gib: %s, "
"cgtsvg_growth_gib: %s, cgtsvg_max_free_gib: %s"
% (hostname, ceph_mon_gib, cgtsvg_growth_gib,
cgtsvg_max_free_gib))
if cgtsvg_growth_gib and (cgtsvg_growth_gib > cgtsvg_max_free_gib):
if ceph_mon_gib:
msg = _(
"Node: %s Total target growth size %s GiB for database "
"(doubled for upgrades), glance, "
"scratch, backup, extension and ceph-mon exceeds "
"growth limit of %s GiB." %
(hostname, cgtsvg_growth_gib, cgtsvg_max_free_gib)
)
else:
msg = _(
"Node: %s Total target growth size %s GiB for database "
"(doubled for upgrades), glance, scratch, "
"backup and extension exceeds growth limit of %s GiB." %
(hostname, cgtsvg_growth_gib, cgtsvg_max_free_gib)
)
raise wsme.exc.ClientSideError(msg)
def check_all_ceph_mon_growth(ceph_mon_gib, host=None):
""" Check all nodes (except controllers) filesystem with growth limitation,
host is used only when mon is creating and check current node,
when mon update, host is None and check all nodes of mon list.
"""
if host is not None:
cgtsvg_max_free_gib = get_node_cgtsvg_limit(host)
check_node_ceph_mon_growth(host, ceph_mon_gib, cgtsvg_max_free_gib)
ceph_mons = pecan.request.dbapi.ceph_mon_get_list()
for mon in ceph_mons:
ceph_mon_host = pecan.request.dbapi.ihost_get(mon['forihostid'])
cgtsvg_max_free_gib = get_node_cgtsvg_limit(ceph_mon_host)
check_node_ceph_mon_growth(ceph_mon_host, ceph_mon_gib,
cgtsvg_max_free_gib)
class SBApiHelper(object):
""" API Helper Class for manipulating Storage Backends.