|
20 | 20 | logger = logging.getLogger("log collector") |
21 | 21 |
|
22 | 22 | TIME_FORMAT = time.strftime("%Y%m%d-%H%M%S") |
23 | | -dir_name = "redis_enterprise_k8s_debug_info_{}".format(TIME_FORMAT) |
24 | 23 |
|
25 | 24 | api_resources = [ |
26 | 25 | "RedisEnterpriseCluster", |
@@ -48,7 +47,8 @@ def run(namespace, output_dir): |
48 | 47 | namespace = get_namespace_from_config() |
49 | 48 |
|
50 | 49 | 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) |
52 | 52 |
|
53 | 53 | make_dir(output_dir) |
54 | 54 |
|
@@ -91,7 +91,8 @@ def get_redis_enterprise_debug_info(namespace, output_dir): |
91 | 91 | return |
92 | 92 |
|
93 | 93 | # 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) |
95 | 96 | rc, out = run_shell_command(cmd) |
96 | 97 | if rc: |
97 | 98 | logger.warning( |
@@ -175,7 +176,7 @@ def archive_files(output_dir): |
175 | 176 | file_name = output_dir + ".tar.gz" |
176 | 177 |
|
177 | 178 | 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") |
179 | 180 | logger.info("Archived files into {}".format(file_name)) |
180 | 181 |
|
181 | 182 | try: |
|
0 commit comments