Repository navigation
mgr/MgrOpRequest: fix mark_finish_mon_command to pass flag_finish_mon_command - #72357
stzuraski898 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The targeted fix is correct and its production-observable behavior is covered by a focused regression test.
Review effort: Balanced
Findings: None
What changed in this PR
Corrects mon-command completion tracking in MgrOpRequest and adds regression coverage.
Changes:
- Uses the finish flag when marking completed mon commands.
- Adds a focused unit test and build target.
| File | Description |
|---|---|
src/mgr/MgrOpRequest.h |
Corrects the completion flag. |
src/test/mgr/test_mgroprequest.cc |
Tests flag and state transitions. |
src/test/mgr/CMakeLists.txt |
Registers the new unit test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
jenkins test windows |
NitzanMordhai
left a comment
There was a problem hiding this comment.
@stzuraski898, please check my comments
0b0742e to
acc40c3
Compare
acc40c3 to
0b5b6fc
Compare
…nish() ReplyOnFinish::ReplyOnFinish() previously called mark_finish_mon_command() in the constructor body, which runs as soon as the Context is allocated -- before monc dispatches the command and before any mon reply is received. This caused the op-tracker to report "mon command finished" for ops that were still waiting on the mon (e.g. during a mon election). Move the call into ReplyOnFinish::finish(), which is invoked by MonClient when the mon reply arrives, so the finish flag is set only after the command has actually completed. The same change is also part of ceph#72357 (main commit "mgr: fix MgrOpRequest mon-command flag tracking", tracked as https://tracker.ceph.com/issues/81340), which additionally fixes mark_finish_mon_command() passing flag_start_mon_command instead of flag_finish_mon_command. The two PRs are related and should be fixed in tandem. Fixes: https://tracker.ceph.com/issues/82136 Assisted-by: Claude Opus 4.8 Signed-off-by: Steven Zuraski <[email protected]>
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
mark_finish_mon_command() was passing flag_start_mon_command to mark_flag_point() — a copy-paste error. The finish flag (1 << 4) was never set; dump_ops_in_flight always showed "start mon command" regardless of whether the mon had replied. ReplyOnFinish also called op->mark_finish_mon_command() in its constructor, before monc->start_mon_command() dispatched the command. dump_ops_in_flight therefore reported "mon command finished" for ops still waiting on the mon (e.g. during an election). Move the call into ReplyOnFinish::finish() so the flag advances only when the mon has actually replied. The ReplyOnFinish change in DaemonServer.cc is the same change made by ceph#73120 (main commit "mgr/DaemonServer: move mark_finish_mon_command into ReplyOnFinish::finish()", tracked as https://tracker.ceph.com/issues/82136). The two PRs are related and should be fixed in tandem. Fixes: https://tracker.ceph.com/issues/81340 Assisted-by: IBM Bob Signed-off-by: Steven Zuraski <[email protected]>
0b5b6fc to
e60b446
Compare
NitzanMordhai
left a comment
There was a problem hiding this comment.
@stzuraski898 please see my comments below
| // kFlagStartMonCommand, not kFlagFinishMonCommand. Any code that calls | ||
| // mark_finish_mon_command() too early (e.g. in a constructor executed before | ||
| // the mon command is dispatched) would make this test fail. | ||
| TEST_F(MgrOpRequestTestHelper, FinishFlagNotSetBeforeFinish) { |
There was a problem hiding this comment.
This test doesn't go through ReplyOnFinish. It only calls mark_start_mon_command() and then mark_finish_mon_command(), which is what MarkFinishMonCommandSetsCorrectFlag already does above. If someone moved the call back into the ReplyOnFinish constructor, this test would still pass, so the comment at line 93 ("would make this test fail") isn't true. I'd drop this test. If we want real coverage of the ordering,
ReplyOnFinish would have to be reachable from a test, and I don't think that's worth it for this fix. Please open a new tracker for that gap like we talked about.
| << req->_get_state_string() << "\""; | ||
| } | ||
|
|
||
| // private flag_*_mon_command values from MgrOpRequest.h |
There was a problem hiding this comment.
Please don't copy the flag values here. MgrOpRequestTestAccess is already a friend of MgrOpRequest, so you can add the real constants to it next to mark_reached_module():
struct MgrOpRequestTestAccess {
static constexpr uint8_t flag_start_mon_command =
MgrOpRequest::flag_start_mon_command;
static constexpr uint8_t flag_finish_mon_command =
MgrOpRequest::flag_finish_mon_command;
static void mark_reached_module(MgrOpRequest* op, const std::string& s) {
op->mark_flag_point_string(MgrOpRequest::flag_reached_module, s);
}
};Then use MgrOpRequestTestAccess::flag_start_mon_command and flag_finish_mon_command in the test instead of 1 << 3 and 1 << 4. That way the test can't drift if the flags get renumbered.
There was a problem hiding this comment.
Should be fixed
mark_finish_mon_command() previously passed flag_start_mon_command to mark_flag_point(), so the finish flag was never recorded and dump_ops_in_flight kept reporting "start mon command" after the mon replied. Add a new test binary (scaffolded from PR ceph#71237) covering: - BasicSetup: sanity-check request creation via OpTracker - MarkFinishMonCommandSetsCorrectFlag: regression test for the flag_start_mon_command copy-paste bug; fails on unfixed code. It checks that mark_start_mon_command() and mark_finish_mon_command() set the start and finish flags respectively and that _get_state_string() reports "mon command finished" afterwards. The tests reach MgrOpRequest's private flag constants through the MgrOpRequestTestAccess friend struct, so they use the real values rather than copies and cannot drift if the flags are renumbered. Fixes: https://tracker.ceph.com/issues/81340 Assisted-by: IBM Bob Signed-off-by: Steven Zuraski <[email protected]>
e60b446 to
1cb2c96
Compare
|
This PR has been added to wip-bharath11-testing-20261201.061332-main. |
mark_finish_mon_command() was copy-pasted from mark_start_mon_command()
without updating the flag constant: it passed flag_start_mon_command
(0x08) to mark_flag_point() instead of flag_finish_mon_command (0x10).
As a result the finish bit (0x10) was never set in the op-tracker flag
word and latest_flag_point was left at the start value, so after a mon
command completed:
"mon command finished" for the finishing op, and
completion never fired.
The method is reachable in production via DaemonServer.cc (mark_finish_mon_command
is called at DaemonServer.cc:1043). The one-line fix passes the
already-defined flag_finish_mon_command constant; the switch statements in
the header already map that bit to the correct "mon command finished"
string.
The copy-paste was introduced in 66efcaa ("mgr: integrate optracker
in ceph-mgr") and never corrected.
Fixes: https://tracker.ceph.com/issues/81340
Assisted-by: Claude Opus 4.8
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.