Repository navigation
[TENT] Add diagnostic core and version CLI - #4154
Conversation
There was a problem hiding this comment.
We expect diagnositics as a subfunction so that cli can be extended in the future.
There was a problem hiding this comment.
Perhaps a tent binary test should be included as well.
|
Thanks for the feedback, @alogfans. I have updated the CLI to expose diagnostics as a subcommand and added a test for the |
hongzhi-gao
left a comment
There was a problem hiding this comment.
Two focused correctness concerns on the current head.
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| #include "tent/thirdparty/nlohmann/json.h" |
There was a problem hiding this comment.
This is installed as a public header, but the install rules do not install tent/thirdparty/nlohmann/json.h. A consumer using the installed tent_diagnostics archive will fail at preprocessing when it includes tent/diagnostics/diagnostic.h. Please install the bundled JSON header (or keep JSON out of the installed API), and ideally compile a tiny consumer against the install tree.
| for (const auto& check : snapshot.checks) { | ||
| nlohmann::json serialized{{"id", check.id}, | ||
| {"outcome", toString(check.outcome)}, | ||
| {"summary", check.summary}, |
There was a problem hiding this comment.
Only DiagnosticEvidence.observed passes through Redactor; summary and remediation here, plus source/field in evidenceToJson(), are emitted verbatim in JSON and text. A collector that puts a peer URI, path, credential-bearing error, or other dynamic detail in one of these fields will leak it even in strict mode. Since the diagnostic output is intended to be shareable, please make these fields fixed text/IDs or add a way to sanitize their dynamic content before rendering.
34adc93 to
d34bb13
Compare
| } // namespace | ||
|
|
||
| int main(int argc, char** argv) { | ||
| if (argc == 2 && std::string_view(argv[1]) == "--help") { |
There was a problem hiding this comment.
There is mature args lib out there, if this cli app isn't a oneshot code and need to be maintained for a long time, prefer using lib like https://github.com/jarro2783/cxxopts, https://github.com/CLIUtils/CLI11
There was a problem hiding this comment.
Thanks. I switched the diagnostics CLI to CLI11 and kept the existing commands and exit codes. The CLI tests pass.
| @@ -0,0 +1,72 @@ | |||
| # Exercise the built CLI, including dispatch, output streams and exit codes. | |||
| if(NOT DEFINED TENT_CLI OR NOT EXISTS "${TENT_CLI}") | |||
There was a problem hiding this comment.
Why cli test is a cmake file? Normally we use bash python or something easy to review.
There was a problem hiding this comment.
Agreed. I replaced the CMake test script with a Python CLI test, still run through CTest. All 11 cases pass.
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
896a300 to
042b7ce
Compare
|
Please using cmake to manage CLI11 dependencies, not copy itself as a single header into codebase. |
|
Hi @0z5a, thanks for this PR — we are building the later diagnostics commands of #2864 on top of it. To help it land, here are ready-made changes for the three review points, as five patches on top of your branch (authorship of your five commits unchanged):
Two small extras in the same series, which the later commands rely on but which stand on their own: Branch: https://github.com/xiaodouzi666/Mooncake/tree/pr/4154-assist — current |
Drop the copied single header under extern/cli11 and resolve CLI11 like the other system dependencies: mooncake_provide_cli11() looks up CLI/CLI.hpp and exposes it as Mooncake::cli11. Builds with TENT enabled call the provider from the top-level and the standalone TENT entry points, and dependencies.sh installs libcli11-dev (cli11-devel where the distribution packages it). The spelling and format exclusions that only existed for the vendored header are removed again.
include/tent/CMakeLists.txt is not added by any build entry point, so the install rule placed there never ran and diagnostic.h was not installed. Install the header from the diagnostics library directory instead, together with tent/thirdparty/nlohmann/json.h, which the public header includes.
Redactor::sanitize() replaces whole field values, which does not help for log lines and error messages copied into a report. Add Redactor::sanitizeText(): - credential assignments (password, token, secret, ...), URL user information, authorization values, rkey/lkey values and raw addresses are replaced in every mode; - in strict mode, deployment strings already passed to sanitize() and any remaining IPv4, IPv6, GID, MAC or node GUID token are replaced by the same pseudonyms sanitize() hands out, so a value keeps one name across fields and text. Each replacement counts towards fields_redacted.
The text renderer printed check evidence only in JSON, so the node, device or link a warning or failure refers to was not visible in the human-readable report. Print the evidence lines of every check that did not pass, between the check line and its remediation.
diagnosticExitCode() only returned 0 or 1. Report a failed collector check (the collector process crashed or timed out, or could not be found) as 3 and a failed internal check as 4, so scripts can tell an unhealthy deployment from a diagnostic run that could not complete. Precedence is 4 over 3 over 1 over 0; 2 stays with the argument parser.
|
Thanks @xiaodouzi666, this is very helpful. I applied the five patches on top of the branch with authorship kept (15389d7, 78ebffd, a41bfde, b0d3ed0, 3fb90c0), so the PR now includes them. Checked locally on macOS with clang 21: the diagnostic unit tests pass (15/15). I haven't checked the CMake path or the CLI tests with CLI11 installed yet. One small mismatch: the comment describes CLI11_DIR as a lookup override, but mooncake_provide_cli11() uses find_path and the cache variable MOONCAKE_CLI11_INCLUDE_DIR, and doesn't read CLI11_DIR. Would you prefer the CMake to honor CLI11_DIR, or should the note be corrected? Happy to collaborate on the next pieces for #2864. |
|
@xiaodouzi666 If you think this patch is mergeable, pls tell me. |
|
@alogfans Yes, I think it's mergeable rn. |
|
@0z5a sorry that was a description error, plz keep the code as it is and correct the note, thx |
Incremental review: Files changed against
main.Description
Implements the first diagnostic-core milestone proposed in #2864:
The CLI links only the diagnostic core and does not initialize transports, metadata clients, devices, or remote connections.
Part of #2864.
Module
mooncake-transfer-engine)mooncake-store)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
cmake --build build-tent-diagnostics-root --target tent_cli tent_diagnostic_test -j 16 ctest --test-dir build-tent-diagnostics-root -R '^tent_diagnostic_test$' --output-on-failure ./build-tent-diagnostics-root/mooncake-transfer-engine/tent/cli/tent version ./build-tent-diagnostics-root/mooncake-transfer-engine/tent/cli/tent version --json ldd ./build-tent-diagnostics-root/mooncake-transfer-engine/tent/cli/tentTest results:
The full pre-commit runner could not bootstrap its GitHub-hosted hook repositories because the test host's TLS connection was interrupted. Equivalent local checks passed with clang-format 20.1.8, cmake-format 0.6.13, codespell 2.2.6, git diff --check, conflict-marker checks, and added-large-file checks.
Checklist
./scripts/code_format.sh(equivalent clang-format 20.1.8 check passed)AI Assistance Disclosure
AI assistance was used for implementation and test support. The submitter is responsible for reviewing and defending the changes.