blob: 9d0f92314c53b9052fd0be78df946170b3ea83ac [file] [log] [blame]
Alex5cace3b2021-11-10 16:40:37 -06001from cfg_checker.agent.fio_runner import get_fio_options
Alexdcb792f2021-10-04 14:24:21 -05002from cfg_checker.common import logger_cli
3from cfg_checker.common.settings import ENV_TYPE_KUBE
4from cfg_checker.helpers import args_utils
5from cfg_checker.modules.ceph import info, bench
6
7command_help = "Ceph Storage information and benchmarks"
8supported_envs = [ENV_TYPE_KUBE]
9
10
11# def _selectClass(_env, strClassHint="checker"):
12# _class = None
13# if _env == ENV_TYPE_SALT:
14# if strClassHint == "info":
15# _class = info.SaltCephInfo
16# elif strClassHint == "bench":
17# _class = bench.SaltCephInfo
18# elif _env == ENV_TYPE_KUBE:
19# if strClassHint == "info":
20# _class = info.KubeCephInfo
21# elif strClassHint == "bench":
22# _class = bench.KubeCephBench
23# if not _class:
24# raise CheckerException(
25# "Unknown hint for selecting Ceph handler Class: '{}'".format(
26# strClassHint
27# )
28# )
29# else:
30# return _class
31
32
33def init_parser(_parser):
34 # network subparser
35 ceph_subparsers = _parser.add_subparsers(dest='type')
36
37 ceph_info_parser = ceph_subparsers.add_parser(
38 'info',
39 help="Gather Ceph Cluster information"
40 )
41
42 ceph_info_parser.add_argument(
43 '--detailed',
44 action="store_true", default=False,
45 help="Print additional details"
46 )
47
48 ceph_info_parser.add_argument(
49 '--tgz',
50 metavar='ceph_tgz_filename',
51 help="HTML filename to save report"
52 )
53
54 ceph_report_parser = ceph_subparsers.add_parser(
55 'report',
56 help="Generate network check report"
57 )
58
59 ceph_report_parser.add_argument(
60 '--html',
61 metavar='ceph_html_filename',
62 help="HTML filename to save report"
63 )
64
65 ceph_bench_parser = ceph_subparsers.add_parser(
66 'bench',
67 help="Run ceph benchmark"
68 )
69
70 ceph_bench_parser.add_argument(
71 '--task-list',
72 metavar='ceph_tasks_filename',
73 help="List file with data for Ceph bench testrun"
74 )
Alex5cace3b2021-11-10 16:40:37 -060075 ceph_bench_parser.add_argument(
76 '--agents',
77 type=int, metavar='agent_count', default=5,
78 help="List file with data for Ceph bench testrun"
79 )
80 ceph_bench_parser.add_argument(
81 '--html',
82 metavar='ceph_html_filename',
83 help="HTML filename to save report"
84 )
85 ceph_bench_parser.add_argument(
86 '--storage-class',
87 metavar='storage_class',
88 help="Storage class to be used in benchmark"
89 )
90 ceph_bench_parser.add_argument(
91 '--task-file',
92 metavar='task-file',
93 help="Task file for benchmark"
94 )
Alexdcb792f2021-10-04 14:24:21 -050095
96 return _parser
97
98
99def do_info(args, config):
100 # Ceph info
101 # Gather ceph info and create an archive with data
102 args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
103 # check tgz
104 _tgzfile = "ceph_info_archive.tgz" if not args.tgz else args.tgz
105
106 # _class = _selectClass(_env)
107 ceph_info = info.KubeCephInfo(config)
108
109 logger_cli.info("# Collecting Ceph cluster information")
Alexdcb792f2021-10-04 14:24:21 -0500110 ceph_info.gather_info()
111
112 # Debug, enable if needed to debug report generation
113 # without actuall data collecting each time
114 # ceph_info.dump_info()
115 # ceph_info.load_info()
116 # end debug
117
Alexdcb792f2021-10-04 14:24:21 -0500118 ceph_info.generate_archive(_tgzfile)
Alexdf9cc3a2021-10-12 14:37:28 -0500119 ceph_info.print_summary()
Alexdcb792f2021-10-04 14:24:21 -0500120
121 return
122
123
124def do_report(args, config):
125 # Ceph Report
126 # Gather ceph info and create HTML report with all of the data
127 args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
128 _filename = args_utils.get_arg(args, 'html')
129 logger_cli.info("# Ceph cluster Configuration report")
Alexdcb792f2021-10-04 14:24:21 -0500130
131 # _class = _selectClass(_env)
132 ceph_info = info.KubeCephInfo(config)
133 # Debug, enable if needed to debug report generation
134 # without actuall data collecting each time
135 # ceph_info.load_info()
136 # end debug
137 ceph_info.gather_info()
138 ceph_info.get_transposed_latency_table()
139 ceph_info.get_latest_health_readout()
140 ceph_info.create_html_report(_filename)
141
142 return
143
144
145def do_bench(args, config):
146 # Ceph Benchmark using multiple pods
Alex5cace3b2021-11-10 16:40:37 -0600147 # Prepare the tasks and do synced testrun or a single one
148 logger_cli.info("# Initializing benchmark run")
Alexdcb792f2021-10-04 14:24:21 -0500149 args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
Alex5cace3b2021-11-10 16:40:37 -0600150 _filename = args_utils.get_arg(args, 'html')
151 # agents count option
152 _agents = args_utils.get_arg(args, "agents")
153 logger_cli.info("-> using {} agents".format(_agents))
154 config.bench_agent_count = _agents
155 # storage class
156 _storage_class = args_utils.get_arg(args, "storage_class")
157 logger_cli.info("-> using storage class of '{}'".format(_storage_class))
158 config.bench_storage_class = _storage_class
159 # Task files or options
160 _task_file = args_utils.get_arg(args, "task_file", nofail=True)
161 if not _task_file:
162 logger_cli.info("-> running single run")
163 config.bench_mode = "single"
164 else:
165 logger_cli.info("-> running with tasks from '{}'".format(_task_file))
166 config.bench_task_file = _task_file
167 config.bench_mode = "tasks"
168 _opts = get_fio_options()
169 logger_cli.debug("... default/selected options for fio:")
170 for _k in _opts.keys():
171 # TODO: Update options for single run
172 logger_cli.debug(" {} = {}".format(_k, _opts[_k]))
Alexdcb792f2021-10-04 14:24:21 -0500173
Alex5cace3b2021-11-10 16:40:37 -0600174 # handle option inavailability
Alexdcb792f2021-10-04 14:24:21 -0500175 ceph_bench = bench.KubeCephBench(config)
176
Alexdcb792f2021-10-04 14:24:21 -0500177 # Load tasks
178
179 # Do the testrun
Alex5cace3b2021-11-10 16:40:37 -0600180 ceph_bench.prepare_agents(_opts)
181 if not ceph_bench.run_benchmark(_opts):
182 return
183 ceph_bench.cleanup()
Alexdcb792f2021-10-04 14:24:21 -0500184
185 # Create report
Alex5cace3b2021-11-10 16:40:37 -0600186 ceph_bench.create_report(_filename)
Alexdcb792f2021-10-04 14:24:21 -0500187
188 return