blob: 0f1de01d38bd81901471fb090c4b11052e395132 [file] [log] [blame]
from cfg_checker.agent.fio_runner import get_fio_options
from cfg_checker.common import logger_cli
from cfg_checker.common.settings import ENV_TYPE_KUBE
from cfg_checker.helpers import args_utils
from cfg_checker.modules.ceph import info, bench
command_help = "Ceph Storage information and benchmarks"
supported_envs = [ENV_TYPE_KUBE]
# def _selectClass(_env, strClassHint="checker"):
# _class = None
# if _env == ENV_TYPE_SALT:
# if strClassHint == "info":
# _class = info.SaltCephInfo
# elif strClassHint == "bench":
# _class = bench.SaltCephInfo
# elif _env == ENV_TYPE_KUBE:
# if strClassHint == "info":
# _class = info.KubeCephInfo
# elif strClassHint == "bench":
# _class = bench.KubeCephBench
# if not _class:
# raise CheckerException(
# "Unknown hint for selecting Ceph handler Class: '{}'".format(
# strClassHint
# )
# )
# else:
# return _class
def init_parser(_parser):
# network subparser
ceph_subparsers = _parser.add_subparsers(dest='type')
ceph_info_parser = ceph_subparsers.add_parser(
'info',
help="Gather Ceph Cluster information"
)
ceph_info_parser.add_argument(
'--detailed',
action="store_true", default=False,
help="Print additional details"
)
ceph_info_parser.add_argument(
'--tgz',
metavar='ceph_tgz_filename',
help="HTML filename to save report"
)
ceph_report_parser = ceph_subparsers.add_parser(
'report',
help="Generate network check report"
)
ceph_report_parser.add_argument(
'--html',
metavar='ceph_html_filename',
help="HTML filename to save report"
)
ceph_bench_parser = ceph_subparsers.add_parser(
'bench',
help="Run ceph benchmark"
)
ceph_bench_parser.add_argument(
'--task-list',
metavar='ceph_tasks_filename',
help="List file with data for Ceph bench testrun"
)
ceph_bench_parser.add_argument(
'--agents',
type=int, metavar='agent_count', default=5,
help="List file with data for Ceph bench testrun"
)
ceph_bench_parser.add_argument(
'--html',
metavar='ceph_html_filename',
help="HTML filename to save report"
)
ceph_bench_parser.add_argument(
'--storage-class',
metavar='storage_class',
help="Storage class to be used in benchmark"
)
ceph_bench_parser.add_argument(
'--task-file',
metavar='task-file',
help="Task file for benchmark"
)
ceph_bench_parser.add_argument(
'--no-cleanup',
action="store_true", default=False,
help="Do not cleanup services, agents, pvc, and pv"
)
return _parser
def do_info(args, config):
# Ceph info
# Gather ceph info and create an archive with data
args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
# check tgz
_tgzfile = "ceph_info_archive.tgz" if not args.tgz else args.tgz
# _class = _selectClass(_env)
ceph_info = info.KubeCephInfo(config)
logger_cli.info("# Collecting Ceph cluster information")
ceph_info.gather_info()
# Debug, enable if needed to debug report generation
# without actuall data collecting each time
# ceph_info.dump_info()
# ceph_info.load_info()
# end debug
ceph_info.generate_archive(_tgzfile)
ceph_info.print_summary()
return
def do_report(args, config):
# Ceph Report
# Gather ceph info and create HTML report with all of the data
args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
_filename = args_utils.get_arg(args, 'html')
logger_cli.info("# Ceph cluster Configuration report")
# _class = _selectClass(_env)
ceph_info = info.KubeCephInfo(config)
# Debug, enable if needed to debug report generation
# without actuall data collecting each time
# ceph_info.load_info()
# end debug
ceph_info.gather_info()
ceph_info.get_transposed_latency_table()
ceph_info.get_latest_health_readout()
ceph_info.create_html_report(_filename)
return
def do_bench(args, config):
# Ceph Benchmark using multiple pods
# Prepare the tasks and do synced testrun or a single one
logger_cli.info("# Initializing benchmark run")
args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
_filename = args_utils.get_arg(args, 'html')
# agents count option
config.bench_agent_count = args_utils.get_arg(args, "agents")
logger_cli.info("-> using {} agents".format(config.bench_agent_count))
config.no_cleaning_after_benchmark = args_utils.get_arg(args, "no_cleanup")
# storage class
_storage_class = args_utils.get_arg(args, "storage_class")
logger_cli.info("-> using storage class of '{}'".format(_storage_class))
config.bench_storage_class = _storage_class
# Task files or options
_task_file = args_utils.get_arg(args, "task_file", nofail=True)
if not _task_file:
logger_cli.info("-> running single run")
config.bench_mode = "single"
else:
logger_cli.info("-> running with tasks from '{}'".format(_task_file))
config.bench_task_file = _task_file
config.bench_mode = "tasks"
_opts = get_fio_options()
logger_cli.debug("... default/selected options for fio:")
for _k in _opts.keys():
# TODO: Update options for single run
logger_cli.debug(" {} = {}".format(_k, _opts[_k]))
# handle option inavailability from command line for single mode
# init the Bench class
ceph_bench = bench.KubeCephBench(config)
# Do the testrun
ceph_bench.prepare_agents(_opts)
if not ceph_bench.run_benchmark(_opts):
# No cleaning and/or report if benchmark was not finished
logger_cli.info("# Abnormal benchmark run, no cleaning performed")
return
# Cleaning
if not config.no_cleaning_after_benchmark:
ceph_bench.cleanup()
else:
logger_cli.info(
"# '--no-cleaning' option set. Cleaning not conducted."
)
# Create report
ceph_bench.create_report(_filename)
return