Skip to content

CASSANDRA-20876: Offline nodetool commands should not print network options in help#4871

Open
arvindKandpal-ksolves wants to merge 1 commit into
apache:trunkfrom
arvindKandpal-ksolves:CASSANDRA-20876
Open

CASSANDRA-20876: Offline nodetool commands should not print network options in help#4871
arvindKandpal-ksolves wants to merge 1 commit into
apache:trunkfrom
arvindKandpal-ksolves:CASSANDRA-20876

Conversation

@arvindKandpal-ksolves

Copy link
Copy Markdown
Contributor

Summary

Offline nodetool commands (e.g. history) do not require a JMX connection,
yet their --help output was showing network-related options like --host,
--port, --password, etc. This is misleading and unnecessary.

Changes

  • AbstractCommand.java: Added a public isOfflineCommand() method that
    safely wraps the existing protected shouldConnect() to expose whether a
    command requires a JMX connection.
  • CassandraCliHelpLayout.java: Updated parentCommandOptionsWithJmxOptions()
    to suppress JmxConnect options from help output when the command is offline.
    NodetoolCommand options are still always shown for backwards compatibility.
  • test/resources/nodetool/help/history: Updated help snapshot to reflect
    the corrected output — JMX network options are no longer shown for history.

patch by Arvind Kandpal; reviewed by TBD for CASSANDRA-20876

…ptions in help

- Added isOfflineCommand() to AbstractCommand to publicly expose whether a command requires a JMX connection
- Updated CassandraCliHelpLayout to suppress JmxConnect options in help output for offline commands
- Updated help snapshot for 'history' to reflect the correct output
@smiklosovic smiklosovic requested a review from Mmuzaf June 8, 2026 10:42
{
try
{
return !shouldConnect();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arvindKandpal-ksolves The problem with the current approach is exactly that isOfflineCommand() calls shouldConnect(), which is an execution-flow method, intentionally runtim-overridable and side-effecting (that's why it declares throws ExecutionException). See the Sjk (where the 'locality' is runtime dependent) command and check the test NodetoolHelpCommandsOutputTest.

As for the history command we know in advance that it is local, and this knowledge should be a part of command metdata.

So the right fix is to make this knowledge to be a part of command hierary: so either create a LocalCommand marker interface, or AbstractLocalCommand extends AbstractCommand. Then in the Layout class, check whether the command is local by examining the class it extends.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants