Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccmlib/scylla_node.py: use native scylla nodetool when it's available #573

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ccmlib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,17 @@ def nodetool(self, cmd, capture_output=True, wait=True, timeout=None, verbose=Tr
if not isinstance(nodetool, list):
nodetool = [nodetool]
# see https://www.oracle.com/java/technologies/javase/8u331-relnotes.html#JDK-8278972
nodetool.extend(['-h', host, '-p', str(self.jmx_port), '-Dcom.sun.jndi.rmiURLParsing=legacy'])
nodetool.extend(cmd.split())
args = ['-h', host, '-p', str(self.jmx_port), '-Dcom.sun.jndi.rmiURLParsing=legacy']
if len(nodetool) > 1:
nodetool.extend(cmd.split())
# put args at the end of command line options, as "scylla nodetool"
# expects them as options of the subcommand
nodetool.extend(args)
else:
# while java-based tool considers them as options of the nodetool
# itself
nodetool.extend(args)
nodetool.extend(cmd.split())

return self._do_run_nodetool(nodetool, capture_output, wait, timeout, verbose)

Expand Down
11 changes: 9 additions & 2 deletions ccmlib/scylla_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,16 +776,23 @@ def _update_jmx_pid(self, wait=True):
self.jmx_pid = None

def nodetool(self, cmd, capture_output=True, wait=True, timeout=None, verbose=True):
if not self.has_jmx:
try:
# nodetool subcommand was added in 5.5, so check if it is available
# before using it.
nodetool = [os.path.join(self.get_bin_dir(), "scylla"), "nodetool"]
subprocess.check_call(nodetool + ["help"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
if self.is_docker():
host = 'localhost'
else:
host = self.address()
nodetool = [os.path.join(self.get_bin_dir(), "scylla"), "nodetool"]
nodetool.extend(['-h', host, '-p', '10000'])
nodetool.extend(cmd.split())
return self._do_run_nodetool(nodetool, capture_output, wait, timeout, verbose)
except subprocess.CalledProcessError:
pass

# the java nodetool depends on JMX
assert self.has_jmx
# Fall-back to the java nodetool for pre 5.5.0~dev versions, which don't yet have the native nodetool
# Kill scylla-jmx in case of timeout, to supply enough debugging information

Expand Down
Loading