Skip to content

tentacle: pybind/mgr: update modules to use independent CLICommand subtypes with distinct COMMAND attributes - #67511

Merged
batrick merged 9 commits into
ceph:tentaclefrom
NitzanMordhai:wip-66467-tentacle
Apr 17, 2026
Merged

batrick merged 9 commits into
ceph:tentaclefrom
NitzanMordhai:wip-66467-tentacle

Conversation

@NitzanMordhai

@NitzanMordhai NitzanMordhai commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

Backports #66467 and #67254

  • pybind/.../dashboard: misc automatic linter fixes
  • pybind/mgr/mgr_module: support per-module CLICommand instances and globals
  • pybind/mgr: mechanically fix simple users to not import CLI*Command
  • pybind/orchestrator,cephadm: replace CLICommandMeta
  • pybind/mgr/smb: adapt SMBCommand to use CLICommandBase
  • pybind/mgr/tests/test_object_format: update DecoDemo to use fresh CLICommand
  • pybind/mgr/dashboard: create DBCLICommand, use throughout
  • pybind/mgr: add per-module CLICommand instances to remaining modules

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@NitzanMordhai
NitzanMordhai force-pushed the wip-66467-tentacle branch 2 times, most recently from 5fb972e to dd13111 Compare April 16, 2026 17:15
Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit ff86398)
…obals

Otherwise, the class members on MgrModule and CLICommand are global to all
modules in the same interpreter.

Following commits will introduce a per-module CLICommand types for each
module.

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit 2d79ae6)
The next commit will introduce module specific CLICommand classes.

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit 9099c68)
orchestrator and cephadm relied on CLICommandMeta to bypass the global
behavior of CLICommand.  That is no longer a problem, so replace
CLICommandMeta with OrchestratorCLICommandBase to preserve the magic
error wrapping.

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit 776abe4)
@batrick

batrick commented Apr 16, 2026

Copy link
Copy Markdown
Member

retest this please

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit a58d20c)
…Command

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit d8acddc)
Also moves Command from mgr_module to DBCommand in dashboard/cli.py
since dashboard is the only user and this way it can directly use
DBCLICommand.

Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit 9fe5a64)
Signed-off-by: Samuel Just <[email protected]>
(cherry picked from commit 4aa9e24)

Conflicts:
  - src/pybind/mgr/prometheus/module.py
	  CLIReadCommand/CLIWriteCommand removed from imports, not yet in tentacle - kept tentacle version
  - src/pybind/mgr/orchestrator/module.py
      _cert_store_key_ls, _cert_store_cert_ls - signature changed in main, kept tentacle version
	  _cert_store_entity_ls - function renamed in main, kept tentacle name
	  _cert_store_entity_ls - function name changed in main but not in tentacle
  - src/pybind/mgr/smb/cli.py
	  typing imports differ between main and tentacle - manually reconciled
	  error_wrapper not backported to tentacle - removed from cherry-pick
  - src/pybind/mgr/mirroring/module.py
	  import differs between main and tentacle - manually kept tentacle imports
  - src/pybind/mgr/pg_autoscaler/module.py
      get_scaling_threshold not backported to tentacle - removed that change
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test docs

@batrick

batrick commented Apr 17, 2026

Copy link
Copy Markdown
Member

jenkins test make check

@batrick

batrick commented Apr 17, 2026

Copy link
Copy Markdown
Member

jenkins test docs

@batrick

batrick commented Apr 17, 2026

Copy link
Copy Markdown
Member
[rtd-command-info] start-time: 2026-04-17T12:31:29.534311Z, end-time: 2026-04-17T12:31:35.132697Z, duration: 5, exit-code: 2
python -m sphinx -T -b dirhtml -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html
Running Sphinx v6.2.1
making output directory... done
Top Level States:  ['PeeringMachine']
building [mo]: targets for 0 po files that are out of date
writing output... 
building [dirhtml]: targets for 563 source files that are out of date
updating environment: [new config] 563 added, 0 changed, 0 removed
reading sources... [  0%] api/index
reading sources... [  0%] api/mon_command_api
loading mgr module 'snap_schedule'...

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/cmd/build.py", line 285, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/application.py", line 353, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 311, in build_update
    self.build(to_build,
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 328, in build
    updated_docnames = set(self.read())
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 435, in read
    self._read_serial(docnames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 456, in _read_serial
    self.read_doc(docname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 512, in read_doc
    publisher.publish()
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/core.py", line 224, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/io.py", line 108, in read
    self.parse()
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/sphinx/parsers.py", line 80, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
    self.explicit_list(blank_finish)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/envs/67511/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67511/doc/_ext/ceph_commands.py", line 349, in run
    commands = sum([self._collect_module_commands(name) for name in modules], [])
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67511/doc/_ext/ceph_commands.py", line 349, in <listcomp>
    commands = sum([self._collect_module_commands(name) for name in modules], [])
  File "/home/docs/checkouts/readthedocs.org/user_builds/ceph/checkouts/67511/doc/_ext/ceph_commands.py", line 319, in _collect_module_commands
    assert isinstance(m.COMMANDS, list)
AttributeError: type object 'Module' has no attribute 'COMMANDS'

@NitzanMordhai

@yaarith

yaarith commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

We need to backport #67254.

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]>
(cherry picked from commit 77efb41)
@batrick
batrick requested a review from a team as a code owner April 17, 2026 19:02
@batrick
batrick merged commit 51864af into ceph:tentacle Apr 17, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in Ceph-Dashboard Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants