Skip to content

Commit 0f97c51

Browse files
Merge pull request ceph#64038 from NitzanMordhai/wip-nitzan-mon-ops-historic-dump
monitor: Enhance historic ops command output and error handling
2 parents 6a24529 + 5edb409 commit 0f97c51

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

src/mon/MonCommands.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,15 @@ COMMAND_WITH_FLAG("dump_historic_ops",
15241524
"show recent ops",
15251525
"mon", "r",
15261526
FLAG(TELL))
1527+
COMMAND_WITH_FLAG("dump_historic_ops_by_duration",
1528+
"show recent ops sorted by duration",
1529+
"mon", "r",
1530+
FLAG(TELL))
15271531
COMMAND_WITH_FLAG("dump_historic_slow_ops",
15281532
"show recent slow ops",
15291533
"mon", "r",
15301534
FLAG(TELL))
1535+
COMMAND_WITH_FLAG("dump_ops_in_flight",
1536+
"show the ops currently in flight",
1537+
"mon", "r",
1538+
FLAG(TELL))

src/mon/Monitor.cc

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -375,28 +375,45 @@ int Monitor::do_admin_command(
375375
start_election();
376376
elector.stop_participating();
377377
out << "stopped responding to quorum, initiated new election";
378-
} else if (command == "ops") {
379-
(void)op_tracker.dump_ops_in_flight(f);
380378
} else if (command == "sessions") {
381379
f->open_array_section("sessions");
382380
for (auto p : session_map.sessions) {
383381
f->dump_object("session", *p);
384382
}
385383
f->close_section();
386-
} else if (command == "dump_historic_ops") {
387-
if (!op_tracker.dump_historic_ops(f)) {
388-
err << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
389-
please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
390-
}
391-
} else if (command == "dump_historic_ops_by_duration" ) {
392-
if (op_tracker.dump_historic_ops(f, true)) {
393-
err << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
394-
please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
395-
}
396-
} else if (command == "dump_historic_slow_ops") {
397-
if (op_tracker.dump_historic_slow_ops(f, {})) {
398-
err << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
399-
please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
384+
} else if (command == "dump_ops_in_flight" ||
385+
command == "ops" ||
386+
command == "dump_historic_ops" ||
387+
command == "dump_historic_ops_by_duration" ||
388+
command == "dump_historic_slow_ops") {
389+
const string error_str = "op_tracker tracking is not enabled now, so no ops are tracked currently, \
390+
even those get stuck. Please enable \"mon_enable_op_tracker\", and the tracker \
391+
will start to track new ops received afterwards.";
392+
if (command == "dump_historic_ops") {
393+
if (!op_tracker.dump_historic_ops(f)) {
394+
err << error_str;
395+
r = -EINVAL;
396+
goto abort;
397+
}
398+
} else if (command == "dump_historic_ops_by_duration" ) {
399+
if (!op_tracker.dump_historic_ops(f, true)) {
400+
err << error_str;
401+
r = -EINVAL;
402+
goto abort;
403+
}
404+
} else if (command == "dump_historic_slow_ops") {
405+
if (!op_tracker.dump_historic_slow_ops(f, {})) {
406+
err << error_str;
407+
r = -EINVAL;
408+
goto abort;
409+
}
410+
} else if (command == "ops" ||
411+
command == "dump_ops_in_flight") {
412+
if (!op_tracker.dump_ops_in_flight(f)) {
413+
err << error_str;
414+
r = -EINVAL;
415+
goto abort;
416+
}
400417
}
401418
} else if (command == "quorum") {
402419
string quorumcmd;
@@ -647,7 +664,8 @@ std::vector<std::string> Monitor::get_tracked_keys() const noexcept
647664
"mon_osdmap_full_prune_txsize"s,
648665
// debug options - observed, not handled
649666
"mon_debug_extra_checks"s,
650-
"mon_debug_block_osdmap_trim"s
667+
"mon_debug_block_osdmap_trim"s,
668+
"mon_enable_op_tracker"s,
651669
};
652670
}
653671

@@ -687,6 +705,10 @@ void Monitor::handle_conf_change(const ConfigProxy& conf,
687705
scrub_update_interval(scrub_interval);
688706
}});
689707
}
708+
709+
if (changed.count("mon_enable_op_tracker")) {
710+
op_tracker.set_tracking(conf.get_val<bool>("mon_enable_op_tracker"));
711+
}
690712
}
691713

692714
void Monitor::update_log_clients()

0 commit comments

Comments
 (0)