Skip to content

Commit

Permalink
scylla_node: switch from --scylla-yaml-file to SCYLLA_CONF env va…
Browse files Browse the repository at this point in the history
…riable

since the `scylla sstable` code doesn't fallback into any other option but reading
schema from sstable of system tables, if `--scylla-yaml-file` is used.

switching to `SCYLLA_CONF` env variable should make the tool use other fallback options
like reading the assuming the schema from the sstable we want to read.

Ref: scylladb/scylla-enterprise#4660
  • Loading branch information
fruch committed Sep 10, 2024
1 parent 102c03f commit 7343614
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ccmlib/scylla_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def gnutls_config_file(self):
return str(candidate)
raise ValueError(f"gnutls.config wasn't found in any path: {candidates}")

def run_scylla_sstable(self, command, additional_args=None, keyspace=None, datafiles=None, column_families=None, batch=False, text=True):
def run_scylla_sstable(self, command, additional_args=None, keyspace=None, datafiles=None, column_families=None, batch=False, text=True, env=None):
"""Invoke scylla-sstable, with the specified command (operation) and additional_args.
For more information about scylla-sstable, see https://docs.scylladb.com/stable/operating-scylla/admin-tools/scylla-sstable.html.
Expand Down Expand Up @@ -1512,8 +1512,9 @@ def do_invoke(sstables):
else:
return stdout.encode('utf-8'), stderr.encode('utf-8')
common_args = [scylla_path, "sstable", command] + additional_args
env = self._get_environ()
res = subprocess.run(common_args + sstables, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=text, check=False, env=env)
_env = self._get_environ()
_env.update(env or {})
res = subprocess.run(common_args + sstables, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=text, check=False, env=_env)
if res.returncode:
raise ToolError(command=' '.join(common_args + sstables), exit_status=res.returncode, stdout=res.stdout, stderr=res.stderr)
return (res.stdout, res.stderr)
Expand Down Expand Up @@ -1698,7 +1699,8 @@ def dump_sstable_scylla_metadata(self,
for the JSON schema of it.
"""

additional_args = ['--scylla-yaml-file', str(Path(self.get_conf_dir()) / common.SCYLLA_CONF)]
additional_args = []
env = {'SCYLLA_CONF': str(Path(self.get_conf_dir()))}
if keyspace:
additional_args += ['--keyspace', keyspace]

Expand All @@ -1711,7 +1713,8 @@ def dump_sstable_scylla_metadata(self,
column_families=[column_family],
datafiles=datafiles,
batch=True,
text=False)
text=False,
env=env)
assert '' in sstable_stats
stdout, _ = sstable_stats['']
return json.loads(stdout.decode('utf-8', 'ignore'))['sstables']
Expand Down

0 comments on commit 7343614

Please sign in to comment.