Skip to content

Commit

Permalink
[collect] Review suggestions
Browse files Browse the repository at this point in the history
Inherit-config-file as toggle
No changes will be made
Long-standing cleanup behavior

Signed-off-by: Trevor Benson <[email protected]>
  • Loading branch information
TrevorBenson committed Nov 26, 2024
1 parent b2d5a71 commit 2922e7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
15 changes: 7 additions & 8 deletions sos/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SoSCollector(SoSComponent):
'encrypt_pass': '',
'group': None,
'image': '',
'inherit_config_file': None,
'inherit_config_file': False,
'force_pull_image': True,
'skip_cleaning_files': [],
'jobs': 4,
Expand Down Expand Up @@ -465,15 +465,14 @@ def add_parser_options(cls, parser):
choices=['auto', 'https', 'ftp', 'sftp',
's3'],
help="Manually specify the upload protocol")
collect_grp.add_argument('--inherit-config-file', type=str,
default=None,
help='Path to a local config file to'
' copy to the remote node and use with'
' sos report')
collect_grp.add_argument('--inherit-config-file', default=False,
action='store_true',
help='Use the config file from the collector '
'for all nodes to use with sos report')
collect_grp.add_argument('--node-config-file', type=str,
default=None,
help='Path to a config file on the'
' remote node to use with sos report')
help='Path to an existing config file on the '
'nodes to use with sos report')

# Group the cleaner options together
cleaner_grp = parser.add_argument_group(
Expand Down
13 changes: 3 additions & 10 deletions sos/collector/sosnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,17 +769,14 @@ 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 = os.path.join(self.tmpdir,
'remote_sos.conf')
self.run_command(f"mkdir -pv {self.tmpdir}",
timeout=10)
remote_config = f"/tmp/{self.tmpdir.split('/')[-1]}.conf"
self._transport.copy_file_to_remote(
self.opts.inherit_config_file,
self.opts.config_file,
remote_config)
config_file_arg = f'--config-file={remote_config}'
else:
config_file_arg = (
f'--config-file={self.opts.inherit_config_file}')
f'--config-file={self.opts.config_file}')
self.sos_cmd = (
f"{self.sos_cmd} {config_file_arg}"
if config_file_arg else self.sos_cmd)
Expand All @@ -789,10 +786,6 @@ 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 2922e7b

Please sign in to comment.