Skip to content

Commit 08d1ce4

Browse files
author
Roey Prat
committed
RED-32089 kubectl cp should include destination filename.
Move output_dir_name setting to where it is used. (cherry picked from commit 990413f)
1 parent 0eef667 commit 08d1ce4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

log_collector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
logger = logging.getLogger("log collector")
2121

2222
TIME_FORMAT = time.strftime("%Y%m%d-%H%M%S")
23-
dir_name = "redis_enterprise_k8s_debug_info_{}".format(TIME_FORMAT)
2423

2524
api_resources = [
2625
"RedisEnterpriseCluster",
@@ -48,7 +47,8 @@ def run(namespace, output_dir):
4847
namespace = get_namespace_from_config()
4948

5049
if not output_dir:
51-
output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), dir_name)
50+
output_dir_name = "redis_enterprise_k8s_debug_info_{}".format(TIME_FORMAT)
51+
output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), output_dir_name)
5252

5353
make_dir(output_dir)
5454

@@ -91,7 +91,8 @@ def get_redis_enterprise_debug_info(namespace, output_dir):
9191
return
9292

9393
# copy package from RS pod
94-
cmd = "kubectl -n {} cp {}:{} {}".format(namespace, pod_name, debug_file, output_dir)
94+
output_path = os.path.join(output_dir, debug_file)
95+
cmd = "kubectl -n {} cp {}:{} {}".format(namespace, pod_name, debug_file, output_path)
9596
rc, out = run_shell_command(cmd)
9697
if rc:
9798
logger.warning(
@@ -175,7 +176,7 @@ def archive_files(output_dir):
175176
file_name = output_dir + ".tar.gz"
176177

177178
with tarfile.open(file_name, "w|gz") as tar:
178-
tar.add(output_dir, arcname=dir_name + ".tar.gz")
179+
tar.add(output_dir, arcname=file_name + ".tar.gz")
179180
logger.info("Archived files into {}".format(file_name))
180181

181182
try:

0 commit comments

Comments
 (0)