From c3f8fba04a629f2f3e70d0f5443a42de54426bf2 Mon Sep 17 00:00:00 2001
From: Melissa Li
Date: Tue, 3 Aug 2021 13:34:06 -0400
Subject: [PATCH] mgr/cephadm: refactor `_set_maintenance_health_check` to use
`set_health_warning` helper
Fixes: https://tracker.ceph.com/issues/44414
Signed-off-by: Melissa Li
---
src/pybind/mgr/cephadm/module.py | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py
index 2aeaedded1f68..ef0a32568e154 100644
--- a/src/pybind/mgr/cephadm/module.py
+++ b/src/pybind/mgr/cephadm/module.py
@@ -1533,16 +1533,10 @@ Then run the following:
in_maintenance = self.inventory.get_host_with_state("maintenance")
if not in_maintenance:
- if 'HOST_IN_MAINTENANCE' in self.health_checks:
- del self.health_checks["HOST_IN_MAINTENANCE"]
+ self.remove_health_warning('HOST_IN_MAINTENANCE')
else:
s = "host is" if len(in_maintenance) == 1 else "hosts are"
- self.health_checks["HOST_IN_MAINTENANCE"] = {
- "severity": "warning",
- "summary": f"{len(in_maintenance)} {s} in maintenance mode",
- "detail": [f"{h} is in maintenance" for h in in_maintenance],
- }
- self.set_health_checks(self.health_checks)
+ self.set_health_warning("HOST_IN_MAINTENANCE", f"{len(in_maintenance)} {s} in maintenance mode", 1, [f"{h} is in maintenance" for h in in_maintenance])
@handle_orch_error
@host_exists()
--
2.39.5