Skip to content

Commit

Permalink
fix(BaseNode): define startup_script_remote_path as a class attributes
Browse files Browse the repository at this point in the history
startup_script_remote_path is defined as a class attribute of BaseNode
to allow attribute rewriting in child classes.

It's relevant for DB nodes created in Cloud. /tmp directory is mounted
with noexec option there what makes script execution impossible there.
To resolve it, startup_script_remote_path will be rewritten in Cloud
node class (ScyllaCloudMachineNode) to any from where script execution
will be allowed.
  • Loading branch information
mikliapko committed Dec 23, 2024
1 parent bc3552a commit 0d695f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sdcm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ def __init__(self, name, parent_cluster, ssh_login_info=None, base_logdir=None,
self._node_rack = None
self._is_zero_token_node = False

self.startup_script_remote_path = None

def _is_node_ready_run_scylla_commands(self) -> bool:
"""
When node is just created and started to configure, during first node initializing, it is impossible to connect to the node yet and
Expand Down Expand Up @@ -2911,17 +2913,19 @@ def run_cqlsh(self, cmd, keyspace=None, timeout=120, verbose=True, split=False,
return cqlsh_out if not split else list(map(str.strip, cqlsh_out.stdout.splitlines()))

def run_startup_script(self):
startup_script_remote_path = '/tmp/sct-startup.sh'
if not self.startup_script_remote_path:
self.startup_script_remote_path = "/tmp/startup_script.sh"

with tempfile.NamedTemporaryFile(mode='w+', delete=False, encoding='utf-8') as tmp_file:
tmp_file.write(self.test_config.get_startup_script())
tmp_file.flush()
self.remoter.send_files(src=tmp_file.name, dst=startup_script_remote_path) # pylint: disable=not-callable
self.remoter.send_files(
src=tmp_file.name, dst=self.startup_script_remote_path) # pylint: disable=not-callable

cmds = dedent("""
chmod +x {0}
{0}
""".format(startup_script_remote_path))
""".format(self.startup_script_remote_path))

result = self.remoter.run("sudo bash -ce '%s'" % cmds)
LOGGER.debug(result.stdout)
Expand Down

0 comments on commit 0d695f4

Please sign in to comment.