]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add exception handling to ceph health mute 55117/head
authordradjenovic <dradjenovic@digitalocean.com>
Tue, 25 Oct 2022 20:47:10 +0000 (20:47 +0000)
committerPrashant D <pdhange@redhat.com>
Tue, 9 Jan 2024 21:22:31 +0000 (16:22 -0500)
Signed-off-by: Daniel Radjenovic <dradjenovic@digitalocean.com>
(cherry picked from commit 08abc31359345751432701de36b00d207d3fb6f6)

src/mon/HealthMonitor.cc

index 3adbdc3de59f907ed3e15a3975a9e4af3ae8a542..6eed2b0f05bc35d1b5406e1b41960505fb433f9c 100644 (file)
@@ -300,13 +300,19 @@ bool HealthMonitor::prepare_command(MonOpRequestRef op)
     cmd_getval(cmdmap, "sticky", sticky);
     string ttl_str;
     utime_t ttl;
+    std::chrono::seconds secs;
     if (cmd_getval(cmdmap, "ttl", ttl_str)) {
-      auto secs = parse_timespan(ttl_str);
-      if (secs == 0s) {
-       r = -EINVAL;
-       ss << "not a valid duration: " << ttl_str;
-       goto out;
+      try {
+        secs = parse_timespan(ttl_str);
+        if (secs == 0s) {
+          throw std::invalid_argument("timespan = 0");
+        }
+      } catch (const std::invalid_argument& e) {
+        ss << "invalid duration: " << ttl_str << " (" << e.what() << ")";
+        r = -EINVAL;
+        goto out;
       }
+      
       ttl = ceph_clock_now();
       ttl += std::chrono::duration<double>(secs).count();
     }