diff options
author | dradjenovic <dradjenovic@digitalocean.com> | 2022-10-25 22:47:10 +0200 |
---|---|---|
committer | dradjenovic <dradjenovic@digitalocean.com> | 2022-11-08 17:52:52 +0100 |
commit | 08abc31359345751432701de36b00d207d3fb6f6 (patch) | |
tree | cedb89ab201a35847e31a2afb73a0498aea9c436 /src/mon | |
parent | Merge pull request #48792 from zdover23/wip-doc-2022-11-08-glossary-ceph-clus... (diff) | |
download | ceph-08abc31359345751432701de36b00d207d3fb6f6.tar.xz ceph-08abc31359345751432701de36b00d207d3fb6f6.zip |
mon: add exception handling to ceph health mute
Signed-off-by: Daniel Radjenovic <dradjenovic@digitalocean.com>
Diffstat (limited to 'src/mon')
-rw-r--r-- | src/mon/HealthMonitor.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index 3adbdc3de59..6eed2b0f05b 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -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(); } |