11import json
22import os
33import subprocess
4+ import uuid
45from dataclasses import dataclass
56from 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