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

@smiklosovic smiklosovic requested a review from Mmuzaf June 8, 2026 10:42
Comment thread src/java/org/apache/cassandra/tools/nodetool/AbstractCommand.java Outdated
@arvindKandpal-ksolves

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @Mmuzaf!

You're completely right about the potential side effects of calling shouldConnect(). I've updated the PR based on your suggestion: I reverted the previous approach, introduced a LocalCommand marker interface, made the History command implement it, and updated CassandraCliHelpLayout to just check instanceof LocalCommand statically.

Let me know if this looks good!

@Mmuzaf

Mmuzaf commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@arvindKandpal-ksolves , please also add a test to ensure that none of the commands which implement LocalCommand establish a connection. Otherwise looks good!

…ptions in help

- Introduced LocalCommand marker interface to identify commands that execute purely locally without a JMX connection.
- Updated History command to implement LocalCommand.
- Updated CassandraCliHelpLayout to check for LocalCommand instead of calling execution-flow methods, safely suppressing JMX options for offline commands.
@arvindKandpal-ksolves

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @Mmuzaf!

Added the test testLocalCommandsShouldNotConnect in NodetoolClassHierarchyTest
to ensure all LocalCommand implementations do not establish a JMX connection.
Also restored the shouldConnect() override in History as it was needed for the test to pass.

Both HistoryTest and NodetoolClassHierarchyTest pass successfully.

@smiklosovic smiklosovic self-requested a review June 24, 2026 07:05
@smiklosovic smiklosovic self-requested a review June 24, 2026 10:38
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.

3 participants