From: Kamoltat Date: Thu, 6 Apr 2023 17:36:55 +0000 (+0000) Subject: mon/Monitor.cc: exit function if !osdmon()->is_writeable() X-Git-Tag: v19.0.0~1264^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f7c2d51c60c58aeb031ec279a48910bc02444de;p=ceph.git mon/Monitor.cc: exit function if !osdmon()->is_writeable() Problem: In the function `maybe_go_degraded_stretch_mode()` when `osdmon` is not writeable we shouldn't go into `trigger_degraded_stretch_mode` because we will crash at `ceph_assert(osdmon()->is_writeable())`. The current code does not exit `maybe_go_degraded_stretch_mode()` when we are waiting for `osdmon` to be writeable, therefore, we crash. Solution: Exit the function by returning nothing after going into `wait_for_writeable_ctx`, since at that point we would have queued the context and all we have to do is wait for finish context to execute `maybe_go_degraded_stretch_mode` again. Also, added a bit of logging so that user is aware when `osdmon` and `monmon` are not writeable. We fix other parts of the monitor code that are missing the return after `wait_for_writeable_ctx` and `wait_for_readable_ctx` as well. Fixes: https://tracker.ceph.com/issues/59271 Signed-off-by: Kamoltat --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 6dedb142dfa2..234fc5c4c3e3 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6684,7 +6684,9 @@ void Monitor::try_engage_stretch_mode() dout(20) << __func__ << dendl; if (stretch_mode_engaged) return; if (!osdmon()->is_readable()) { + dout(20) << "osdmon is not readable" << dendl; osdmon()->wait_for_readable_ctx(new CMonEnableStretchMode(this)); + return; } if (osdmon()->osdmap.stretch_mode_enabled && monmap->stretch_mode_enabled) { @@ -6767,12 +6769,15 @@ void Monitor::go_recovery_stretch_mode() } if (!osdmon()->is_readable()) { + dout(20) << "osdmon is not readable" << dendl; osdmon()->wait_for_readable_ctx(new CMonGoRecovery(this)); return; } if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoRecovery(this)); + return; } osdmon()->trigger_recovery_stretch_mode(); } @@ -6808,10 +6813,14 @@ void Monitor::maybe_go_degraded_stretch_mode() &matched_down_mons); if (dead) { if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoDegraded(this)); + return; } if (!monmon()->is_writeable()) { + dout(20) << "monmon is not writeable" << dendl; monmon()->wait_for_writeable_ctx(new CMonGoDegraded(this)); + return; } trigger_degraded_stretch_mode(matched_down_mons, matched_down_buckets); } @@ -6861,10 +6870,14 @@ void Monitor::trigger_healthy_stretch_mode() if (!is_degraded_stretch_mode()) return; if (!is_leader()) return; if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoHealthy(this)); + return; } if (!monmon()->is_writeable()) { + dout(20) << "monmon is not writeable" << dendl; monmon()->wait_for_writeable_ctx(new CMonGoHealthy(this)); + return; } ceph_assert(osdmon()->osdmap.recovering_stretch_mode);