RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2216608 - Exception raised by hpssm plugin in plug.setup().
Summary: Exception raised by hpssm plugin in plug.setup().
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sos
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Pavel Moravec
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
: 2221103 (view as bug list)
Depends On:
Blocks: 2221103
TreeView+ depends on / blocked
 
Reported: 2023-06-22 04:49 UTC by Daniel Reynolds
Modified: 2023-07-26 08:38 UTC (History)
11 users (show)

Fixed In Version: sos-4.5.5-2.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2221103 (view as bug list)
Environment:
Last Closed: 2023-07-26 08:37:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:
dareynol: needinfo-
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sosreport sos pull 3285 0 None open [Plugin] Fix exception when calling os.makedirs 2023-06-22 15:10:29 UTC
Red Hat Issue Tracker RHELPLAN-160412 0 None None None 2023-06-22 04:52:50 UTC

Description Daniel Reynolds 2023-06-22 04:49:38 UTC
Description of problem:


Version-Release number of selected component (if applicable):
- sos-4.5.0-1.el8

How reproducible:
- Only on customers specific hardware.  Then, always.


Steps to Reproduce:
1. `sudo sosreport --batch`


Actual results:

Exception running 'hpssm' plugin.
~~~
Please note the 'sosreport' command has been deprecated in favor of the new 'sos' command, E.G. 'sos report'.
Redirecting to 'sos report --batch'

sosreport (version 4.5.0)

[snip]
caught exception in plugin method "hpssm.setup()"
writing traceback to sos_logs/hpssm-plugin-errors.txt
Retrieving Linux Extensions Configuration ...
[snip]

Your sosreport has been generated and saved in:
        /var/tmp/sosreport-dl360x4140-2023-06-07-pmtslmo.tar.xz

 Size   23.51MiB
 Owner  root
 sha256 f8bc2de2ac33af75f518b06ddfa2bf08819d7f1b843d969033d4184d7fcb247e
~~~


Expected results:

No exception running hpssm plugin.

Additional info:

- From 'sos_logs/hpssm-plugin-errors.txt'

    ~~~
    $ cat sos_logs/hpssm-plugin-errors.txt 
    Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/sos/report/__init__.py", line 1217, in setup
        plug.setup()
      File "/usr/lib/python3.6/site-packages/sos/report/plugins/hpssm.py", line 67, in setup
        logpath = self.get_cmd_output_path()
      File "/usr/lib/python3.6/site-packages/sos/report/plugins/__init__.py", line 2167, in get_cmd_output_path
        os.makedirs(cmd_output_path)
      File "/usr/lib64/python3.6/os.py", line 220, in makedirs
        mkdir(name, mode)
    FileExistsError: [Errno 17] File exists: '/var/tmp/sos.8d8v8__a/sosreport-seliics03349-2023-06-08-enmwtcf/sos_commands/hpssm'
    ~~~

- If hpssm plugin is disabled, no exception is raised.

- Clearing /var/tmp of sos directories does not resolve the issue.

Comment 1 Jose Castillo 2023-06-22 09:13:19 UTC
The problem here seems to be that we call the function get_cmd_output_path() with the default values, here:

        logpath = self.get_cmd_output_path()


And by default it tries to create the directory, which in our case has been already created, if I'm reading it correctly:

	def get_cmd_output_path(self, name=None, make=True):                     <-- default is to create dir
		"""Get the path where this plugin will save command output

		:param name: Optionally specify a filename to use as part of the
					 command output path
		:type name: ``str`` or ``None``

		:param make: Attempt to create the command output path
		:type make: ``bool``

		:returns: The path where the plugin will write command output data
				  within the archive
		:rtype: ``str``
		"""
		cmd_output_path = os.path.join(self.archive.get_tmp_dir(),
									   'sos_commands', self.name())
		if name:
			cmd_output_path = os.path.join(cmd_output_path, name)
		if make:
			os.makedirs(cmd_output_path)                    <-- So we end up here attempting to create an already existing dir

I have a couple of ideas about how to solve this, but will need to test them first.

Comment 2 Pavel Moravec 2023-06-22 09:41:54 UTC
(In reply to Jose Castillo from comment #1)
> The problem here seems to be that we call the function get_cmd_output_path()
> with the default values, here:
> 
>         logpath = self.get_cmd_output_path()
> 
> 
> And by default it tries to create the directory, which in our case has been
> already created, if I'm reading it correctly:
> 
> 	def get_cmd_output_path(self, name=None, make=True):                    
> <-- default is to create dir
> 		"""Get the path where this plugin will save command output
> 
> 		:param name: Optionally specify a filename to use as part of the
> 					 command output path
> 		:type name: ``str`` or ``None``
> 
> 		:param make: Attempt to create the command output path
> 		:type make: ``bool``
> 
> 		:returns: The path where the plugin will write command output data
> 				  within the archive
> 		:rtype: ``str``
> 		"""
> 		cmd_output_path = os.path.join(self.archive.get_tmp_dir(),
> 									   'sos_commands', self.name())
> 		if name:
> 			cmd_output_path = os.path.join(cmd_output_path, name)
> 		if make:
> 			os.makedirs(cmd_output_path)                    <-- So we end up here
> attempting to create an already existing dir
> 
> I have a couple of ideas about how to solve this, but will need to test them
> first.

Three *possible* ideas (dont saying the best ones):

1) enhance get_cmd_output_path by optional parameter skip_if_present and call os.makedirs with exist_ok=skip_if_present option (to have plugins the ability to configure it (is there a need for it..?))
2) call the os.makedirs always with exist_ok=True (pragmatically saying, we just want to make it created, right?)
3) put the os.makedirs call into try-catch block and raise a warning in catch branch (likewise 2) but with an extra warn log)

Comment 3 Jose Castillo 2023-06-22 10:41:52 UTC
I'm testing exist_ok=True, because that will catch if the dir has been created up to the point when we call os.makedirs(), because I think this may help better to avoid race conditions.

Comment 4 Jose Castillo 2023-06-22 15:15:39 UTC
Upstream PR can be found here:

https://github.com/sosreport/sos/pull/3285

Comment 5 Jan Jansky 2023-06-30 14:05:33 UTC
Will you be able to test this fix for us when we will have release candidate?

Comment 11 Jan Jansky 2023-07-19 07:08:49 UTC
*** Bug 2221103 has been marked as a duplicate of this bug. ***

Comment 14 Daniel Reynolds 2023-07-20 00:21:42 UTC
Hello Jan,

Have shared the links to the new package with the customer and requested that they test it.

Regards

Comment 20 errata-xmlrpc 2023-07-26 08:37:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sos bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:4279


Note You need to log in before you can comment on or make changes to this bug.