Skip to content

Commit 3f46e87

Browse files
authored
Merge pull request #29511 from ballard26/coll-avoid-cb
cloud_broker: avoid script name collisions during injection
2 parents 113a166 + 55ac858 commit 3f46e87

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/rptest/services/cloud_broker.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import os
33
import subprocess
4+
import uuid
45
from dataclasses import dataclass
56
from typing import Any
67

@@ -97,10 +98,14 @@ def inject_script(self, script_name):
9798
script_path = os.path.join(scripts_dir, script_name)
9899
assert os.path.exists(script_path)
99100

101+
# Avoid this script colliding on the agent node with
102+
# any other scripts with the same name.
103+
unique_script_name = f"{uuid.uuid4()}_{script_name}"
104+
100105
# not using paramiko due to complexity of routing to actual node
101106
# Copy ducktape -> agent
102107
_scp_cmd = self._kubeclient._scp_cmd(
103-
script_path, f"{self._kubeclient._remote_uri}:"
108+
script_path, f"{self._kubeclient._remote_uri}:{unique_script_name}"
104109
)
105110
self.logger.debug(_scp_cmd)
106111
subprocess.check_output(_scp_cmd)
@@ -111,12 +116,14 @@ def inject_script(self, script_name):
111116
"-n",
112117
"redpanda",
113118
"cp",
114-
script_name,
119+
unique_script_name,
115120
f"{self.nodeshell.pod_name}:{remote_path}",
116121
]
117122
self.logger.debug(_cp_cmd)
118123
subprocess.check_output(_cp_cmd)
119-
return
124+
125+
# Remove script from agent node
126+
self._kubeclient._ssh_cmd(["rm", unique_script_name])
120127

121128
def _query_broker(self, path, port=None):
122129
"""

0 commit comments

Comments
 (0)