cfg-checker ceph bench debug part 3
- cleanup procedure
- agent json loading updates
- bool argument detection updates
Related-PROD: PROD-36669
Change-Id: I9e2417a2bfc03883d9a6ef69f60f000cb5bacf54
diff --git a/cfg_checker/modules/ceph/__init__.py b/cfg_checker/modules/ceph/__init__.py
index d3f9581..62941d5 100644
--- a/cfg_checker/modules/ceph/__init__.py
+++ b/cfg_checker/modules/ceph/__init__.py
@@ -185,9 +185,14 @@
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
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)
diff --git a/cfg_checker/modules/ceph/bench.py b/cfg_checker/modules/ceph/bench.py
index dd96a69..5fa4cfd 100644
--- a/cfg_checker/modules/ceph/bench.py
+++ b/cfg_checker/modules/ceph/bench.py
@@ -6,6 +6,7 @@
from time import sleep
from cfg_checker.common import logger_cli
+from cfg_checker.helpers.console_utils import Progress
# from cfg_checker.common.exception import InvalidReturnException
# from cfg_checker.common.exception import ConfigException
# from cfg_checker.common.exception import KubeException
@@ -108,8 +109,8 @@
def _poke_agent(self, url, body, action="GET"):
_datafile = "/tmp/data"
_data = [
- "--data-binary",
- "@" + _datafile,
+ "-d",
+ "@" + _datafile
]
_cmd = [
"curl",
@@ -161,7 +162,7 @@
_h = _s["healthcheck"]["hostname"]
_t = _s['status']
_r = _s["healthcheck"]["ready"]
- if _t != "idle":
+ if _t not in ["idle", "finished"]:
logger_cli.error("Agent status invalid {}:{}".format(_h, _t))
_tt += [False]
else:
@@ -228,11 +229,11 @@
)
# recalc how much is left
diff = (_end - datetime.now()).total_seconds()
- logger_cli.debug("... [{}s]: {}".format(diff, _str))
+ logger_cli.debug("... [{:.2f}s]: {}".format(diff, _str))
# In case end_datetime was in past to begin with
if diff < 0:
break
- logger_cli.info("-> Sleeping for {}s".format(diff/2))
+ logger_cli.info("-> Sleeping for {:.2f}s".format(diff/2))
sleep(diff/2)
if diff <= 0.1:
break
@@ -245,7 +246,30 @@
for _res in self.cleanup_list:
self.master.cleanup_resource_by_name(_res[0], _res[2], ns=_res[1])
- logger_cli.info("# Done cleaning up")
+
+ # Wait for resource to be cleaned
+ _timeout = 120
+ _total = len(self.cleanup_list)
+ logger_cli.info("-> Wait until {} resources cleaned".format(_total))
+ _p = Progress(_total)
+ while True:
+ _g = self.master.get_resource_phase_by_name
+ _l = [_g(r[0], r[2], ns=r[1]) for r in self.cleanup_list]
+ _l = [item for item in _l if item]
+ _idx = _total - len(_l)
+ if len(_l) > 0:
+ _p.write_progress(_idx)
+ else:
+ _p.end()
+ logger_cli.info("# Done cleaning up")
+ break
+ if _timeout > 0:
+ _timeout -= 1
+ else:
+ _p.end()
+ logger_cli.info("# Timed out waiting after 120s.")
+ break
+
return
# Create report