Skip to content

Commit

Permalink
[collect] Temporary directory and cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Trevor Benson <[email protected]>
  • Loading branch information
TrevorBenson committed Nov 26, 2024
1 parent 30909a4 commit d8a835a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sos/collector/sosnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,12 @@ def execute_sos_command(self):
config_file_arg = f'--config-file={self.opts.node_config_file}'
elif self.opts.inherit_config_file:
if not self.local:
remote_config_path = os.path.join('/var/tmp/', 'remote_sos.conf')
self._transport.copy_file_to_remote(self.opts.inherit_config_file, remote_config_path)
config_file_arg = f'--config-file={remote_config_path}'
remote_config = os.path.join(self.tmpdir, 'remote_sos.conf')
self.run_command(f"mkdir -pv {self.tmpdir}",
timeout=10)
self._transport.copy_file_to_remote(self.opts.inherit_config_file,
remote_config)
config_file_arg = f'--config-file={remote_config}'
else:
config_file_arg = f'--config-file={self.opts.inherit_config_file}'
self.sos_cmd = f"{self.sos_cmd} {config_file_arg}" if config_file_arg else self.sos_cmd
Expand All @@ -781,6 +784,10 @@ def execute_sos_command(self):
need_root=True,
use_container=True,
env=self.sos_env_vars)
if self.opts.inherit_config_file and not self.local:
self.run_command(f"rm {remote_config} ; rmdir {self.tmpdir}",
use_shell=True,
need_root=True)
if res['status'] == 0:
for line in res['output'].splitlines():
if fnmatch.fnmatch(line, '*sosreport-*tar*'):
Expand Down

0 comments on commit d8a835a

Please sign in to comment.