From f3b68e375f1e5d74baf4f890c4271dd52c8cc9b8 Mon Sep 17 00:00:00 2001 From: Jacques Heunis Date: Thu, 15 Jan 2026 12:11:11 +0000 Subject: [PATCH] tools/rados: Remove plain text snippets from rados bench JSON output `rados bench` emits performance stats as its output. It is very helpful for this output to be in a machine-readable format and the CLI provides the `--format=json` flag to achieve this. There are some logs that do not respect the formatter flag though, as they provide status updates as the tool is running and do not form part of the output dataset. This prevents the contents of stdout from being valid JSON which destroys the machine-readability of the output. To resolve this we gate those status messages behind a check for the formatter. If any specific formatter is provided we do not emit the status logs. This leaves the plaintext output largely untouched while helping the machine-readable output to be well-formed. Fixes: https://tracker.ceph.com/issues/74370 Signed-off-by: Jacques Heunis --- src/common/obj_bencher.cc | 11 +++++++---- src/tools/rados/rados.cc | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index b4db480a686..63de044122d 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -333,13 +333,14 @@ int ObjBencher::aio_bench( } data.start_time = mono_clock::now(); - out(cout) << "Cleaning up (deleting benchmark objects)" << std::endl; + out(cerr) << "Cleaning up (deleting benchmark objects)" << std::endl; r = clean_up(num_objects, prev_pid, concurrentios); if (r != 0) goto out; timePassed = mono_clock::now() - data.start_time; - out(cout) << "Clean up completed and total clean up time :" << timePassed.count() << std::endl; + out(cerr) << "Clean up completed and total clean up time :" + << timePassed.count() << std::endl; // lastrun file r = sync_remove(run_name_meta); @@ -1244,7 +1245,8 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) { completions_done(); - out(cout) << "Removed " << data.finished << " object" << (data.finished != 1 ? "s" : "") << std::endl; + out(cerr) << "Removed " << data.finished << " object" + << (data.finished != 1 ? "s" : "") << std::endl; return 0; @@ -1431,7 +1433,8 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) { completions_done(); - out(cout) << "Removed " << data.finished << " object" << (data.finished != 1 ? "s" : "") << std::endl; + out(cerr) << "Removed " << data.finished << " object" + << (data.finished != 1 ? "s" : "") << std::endl; return 0; diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 301a4da33e4..42103648b6b 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -3434,7 +3434,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, object_size = op_size; else if (object_size < op_size) op_size = object_size; - cout << "hints = " << (int)hints << std::endl; ret = bencher.aio_bench(operation, seconds, concurrent_ios, op_size, object_size, max_objects, cleanup, hints, run_name, reuse_bench, no_verify); -- 2.47.3