Skip to content

doc/_ext: fix ceph_commands.py for new decorator-based command system - #67254

Merged
tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-doc-build-mgr-module-command
Feb 9, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-doc-build-mgr-module-command

Conversation

@tchaikov

@tchaikov tchaikov commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

After commit 4aa9e24, mgr modules migrated from using a class-level COMMANDS list to decorator-based command registration using per-module CLICommand instances (e.g., @BalancerCLICommand.Read('balancer status')).

This broke the ceph_commands.py Sphinx extension which was hardcoded to expect m.COMMANDS to be a list, causing documentation builds to fail.

But not all modules are using this per-module CLICommand. Some modules are fully migrated (balancer, hello, etc.) and use decorators, while others are partially migrated (volumes, progress, stats, influx, k8sevents, osd_perf_query, osd_support) - they have CLICommand defined but still use the old COMMANDS list.

This fix updates _collect_module_commands() to handle three scenarios:

  1. Fully migrated modules: Check CLICommand.dump_cmd_list() and use it if it returns commands
  2. Partially migrated modules: Fall back to the old COMMANDS list if dump_cmd_list() returns empty
  3. Legacy modules: Use COMMANDS list if CLICommand doesn't exist

This ensures the Sphinx extension works with modules in any migration state, maintaining backwards compatibility while supporting the new decorator pattern.

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

After commit 4aa9e24, mgr modules migrated from using a class-level
COMMANDS list to decorator-based command registration using per-module
CLICommand instances (e.g., @BalancerCLICommand.Read('balancer status')).

This broke the ceph_commands.py Sphinx extension which was hardcoded to
expect m.COMMANDS to be a list, causing documentation builds to fail.

But not all modules are using this per-module CLICommand. Some modules are
fully migrated (balancer, hello, etc.) and use decorators, while others
are partially migrated (volumes, progress, stats, influx, k8sevents,
osd_perf_query, osd_support) - they have CLICommand defined but still
use the old COMMANDS list.

This fix updates _collect_module_commands() to handle three scenarios:

1. Fully migrated modules: Check CLICommand.dump_cmd_list() and use it
   if it returns commands
2. Partially migrated modules: Fall back to the old COMMANDS list if
   dump_cmd_list() returns empty
3. Legacy modules: Use COMMANDS list if CLICommand doesn't exist

This ensures the Sphinx extension works with modules in any migration
state, maintaining backwards compatibility while supporting the new
decorator pattern.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov requested a review from a team as a code owner February 8, 2026 13:01
@tchaikov
tchaikov requested a review from a team February 8, 2026 14:10
@tchaikov

tchaikov commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

@ceph/core Could you please review this change? PR #66467 introduced a regression that's causing all "docs/readthedocs.org:ceph" workflow runs of the pull requests targeting main to fail. Since this workflow is marked as a gatekeeper, it's currently blocking all PRs and should be treated as a blocker.

@anthonyeleven

Copy link
Copy Markdown
Contributor

Checklist please

@tchaikov
tchaikov merged commit 2b91468 into ceph:main Feb 9, 2026
16 of 19 checks passed
@tchaikov
tchaikov deleted the wip-doc-build-mgr-module-command branch February 9, 2026 00:00
@tchaikov

tchaikov commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

i forgot to include a hyper link to the failing build, see https://app.readthedocs.org/projects/ceph/builds/31319220/

Running Sphinx v6.2.1
2	making output directory... done
3	Top Level States:  ['PeeringMachine']
4	building [mo]: targets for 0 po files that are out of date
5	writing output... 
6	building [dirhtml]: targets for 569 source files that are out of date
7	updating environment: [new config] 569 added, 0 changed, 0 removed
8	reading sources... [  0%] api/index
9	reading sources... [  0%] api/mon_command_api
10	loading mgr module 'balancer'...
11	
12	Traceback (most recent call last):
13	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/cmd/build.py", line 285, in build_main
14	    app.build(args.force_all, args.filenames)
15	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/application.py", line 353, in build
16	    self.builder.build_update()
17	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 311, in build_update
18	    self.build(to_build,
19	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 328, in build
20	    updated_docnames = set(self.read())
21	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 435, in read
22	    self._read_serial(docnames)
23	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 456, in _read_serial
24	    self.read_doc(docname)
25	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 512, in read_doc
26	    publisher.publish()
27	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/core.py", line 224, in publish
28	    self.document = self.reader.read(self.source, self.parser,
29	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/io.py", line 108, in read
30	    self.parse()
31	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/readers/__init__.py", line 76, in parse
32	    self.parser.parse(self.input, document)
33	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/sphinx/parsers.py", line 80, in parse
34	    self.statemachine.run(inputlines, document, inliner=self.inliner)
35	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 169, in run
36	    results = StateMachineWS.run(self, input_lines, input_offset,
37	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
38	    context, next_state, result = self.check_line(
39	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
40	    return method(match, context, next_state)
41	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
42	    self.explicit_list(blank_finish)
43	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
44	    newline_offset, blank_finish = self.nested_list_parse(
45	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
46	    state_machine.run(block, input_offset, memo=self.memo,
47	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
48	    results = StateMachineWS.run(self, input_lines, input_offset)
49	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
50	    context, next_state, result = self.check_line(
51	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
52	    return method(match, context, next_state)
53	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
54	    nodelist, blank_finish = self.explicit_construct(match)
55	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
56	    return method(self, expmatch)
57	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
58	    return self.run_directive(
59	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67202/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
60	    result = directive_instance.run()
61	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67202/doc/_ext/ceph_commands.py", line 349, in run
62	    commands = sum([self._collect_module_commands(name) for name in modules], [])
63	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67202/doc/_ext/ceph_commands.py", line 349, in <listcomp>
64	    commands = sum([self._collect_module_commands(name) for name in modules], [])
65	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67202/doc/_ext/ceph_commands.py", line 319, in _collect_module_commands
66	    assert isinstance(m.COMMANDS, list)
67	AttributeError: type object 'Module' has no attribute 'COMMANDS'
68	
69	Exception occurred:
70	  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67202/doc/_ext/ceph_commands.py", line 319, in _collect_module_commands
71	    assert isinstance(m.COMMANDS, list)
72	AttributeError: type object 'Module' has no attribute 'COMMANDS'

@batrick

batrick commented Apr 17, 2026

Copy link
Copy Markdown
Member

Backported via #67511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants