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: v17.2.7~356^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f42ea81c3ed6f00208de2fe7f12901318c2cdb14;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 (cherry picked from commit 7f7c2d51c60c58aeb031ec279a48910bc02444de) --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 630ee723aed4..3325fbd5cd44 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6658,7 +6658,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) { @@ -6741,12 +6743,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(); } @@ -6782,10 +6787,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); } @@ -6835,10 +6844,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);