Enhancement #74508
openAuto-generating CLI help to enforce accuracy
0%
Description
The Ceph CLI tools seem to have long been struggling to keep their documentation current. On multiple occasions over the last couple years I have personally discovered that some valid command I would like to run is not mentioned in the documentation (online or in-application via `--help`), or vice-versa where the documentation suggests a command which is not valid. A quick search of tracker suggests that I am not at all the only user to have encountered this (see for example 40525, 12423, 58310, 44568 etc). This problem can only happen because currently the in-application documentation (emitted when run with `--help`) is a hand-written block of text that needs to be manually maintained by contributors. Evidently this has not always happened.
To fix this problem and avoid it recurring in future, I propose to replace the argument parsing in `radosgw-admin`. In the current scheme `main` contains literally hundreds of root-scope local variables for every possible argument and a long list of "if argv contains this string then set a local variable or call some function". I propose that we instead define (in code) the full tree of possible arguments, each with their own individual documentation and semantics. Once we have that tree we can use it to power generic argument-parsing (consolidating its complexity from the "business logic" of doing what radosgw-admin is actually trying to do). This would have many benefits:
1. We could automatically generate in-application help output, thereby enforcing that it is always 100% complete and accurate. No more undocumented arguments.
2. We could conceivably even go a step further and have `radosgw-admin` itself output the required contents for its own web-based man page. This ensures that the CLI docs always agrees with the web docs.
3. If we leverage library support, we may get "hierarchical help output" almost for free. By this I mean that when a user runs `radosgw-admin --help`, instead of the ~400 lines of text it currently produces, it would give a relatively small amount of output with the top-level commands (e.g `radosgw-admin bucket` or `radosgw-admin user`) and users can then run those with `--help` (e.g `radosgw-admin bucket --help`) to get more context-specific help, thereby providing users with a path to detailed help information without getting overwhelmed.
4. Doing all the parsing at once before applying any logic means we have the option of warning (or even failing) when an unexpected argument is passed. This would help reduce the likelihood of users executing commands with unexpected behaviour (which could have significant consequences in a persistent storage system like Ceph).
5. Since this argument tree would contain information about which flags apply to which (sub)commands, we can reliably show this in the documentation which reduces user confusion. As an example, the online documentation currently specifies that a user can pass in `--bucket` to specify the bucket to which the command applies, but there is no indication of which commands accept that flag.
6. If desired, since the definition is a tree, we could probably more easily split up the code that creates it so that its not all a single large unwieldy blob. We could, for example, have the code for handling lifecycle processing colocated with the code for the CLI commands that invoke it.
Overall the goal is to improve the UX of radosgw-admin, thereby making it easier for new users to get up to speed and growing the community. It's worth pointing out though that none of this is specific to `radosgw-admin`, that's just the tool with which I've experienced the most frustration born of incomplete or inaccurate documentation. The output of `ceph --help` is actually ~50% longer than that of `radosgw-admin` but we have to start somewhere. If this work is a success here then it can serve as an example to the other Ceph CLI tools.
CB Updated by Casey Bodley 10 months ago
- Priority changed from Normal to High
YL Updated by Yuval Lifshitz 10 months ago
- man page: https://github.com/ceph/ceph/blob/main/doc/man/8/radosgw-admin.rst
- admin guide: https://github.com/ceph/ceph/blob/main/doc/radosgw/admin.rst
ideally, these 2 are completly automated.
note that there is also the test file that should match the --help output:
https://github.com/ceph/ceph/blob/main/src/test/cli/radosgw-admin/help.t
as for documenting the commands in various docs, would be nice to eb able to reference the description without manually copying its there. similarly to how we pull into the .rst files the config options documentations using the:
.. confval::
directive.
JH Updated by Jacques Heunis 10 months ago
I mentioned this at the RGW weekly meeting, some notes:
- Several people expressed an interest in having this done
- For any improvements, if we could integrate them with (or build them in underneath) the existing ceph-argparse infrastructure, that would be helpful for maintaining consistency across components and also ease possible future adoption by other tools & components
- Backwards compatibility is always a goal but with appropriate justification (and a deprecation schedule appropriate for the change), it can be workable
- A particularly desired feature is the ability to leverage the in-memory representation of all the commands/args for generating reference docs so that this information can be defined in exactly one place.
- Some ceph tools already use boost's program_options so that is the preferred tooling. However it's not clear if it exposes the configured options after the fact in a way that would enable docs generation outside of the executable (IE to power more than just
--help)
Next steps from my end are to spend more time exploring program_options to see how much of this work it can do for us or if we need to either build additional infrastructure internally or pull in an alternative library.
BK Updated by benaryorg Katze 8 months ago
1. We could automatically generate in-application help output, thereby enforcing that it is always 100% complete and accurate. No more undocumented arguments.
This has bitten be very recently, given that 49 commands of radosgw-admin (as per the code on main at time of writing) are not documented in its help output.
Even more confusingly the help output names several commands which do not exist.
Since radosgw-admin in particular already has SimpleCmd as an abstraction, it would be very easy to factor out descriptions for subcommands into that and generate that part of the help output from it.
This would not affect flags or other options, but it would go a long way to make the tool significantly more usable, and in the short-term would enforce new descriptions for newly added commands.
The effort required to add this functionality should be almost negligible and would serve a lot of users very well as a first iteration.
2. We could conceivably even go a step further and have `radosgw-admin` itself output the required contents for its own web-based man page. This ensures that the CLI docs always agrees with the web docs.
Just as a side-note I would like to remind everyone that help output is meant to list all the commands and what they do, the man-pages (in their various forms) are meant to explain why and how they do things.
The current radosgw-admin web-based man-page is a good example of a manual page which does not provide much information beyond what the command itself should reasonably offer.
Any adjustment to the generation of such pages should (IMHO) be geared towards providing the kind of information which is currently hard to find outside of mailing lists (such as the interplay between bucket sync init and bucket sync run).
This would foster a documentation which contains information befit of a manual, as is the case with the
The Take the excellent ceph-volume lvm prepare documentation this page lists when you would use the tool and why (though I admit that it would be better off with an exhaustive list of all valid options).