Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plugin] Fix exception when calling os.makedirs #3285

Conversation

jcastill
Copy link
Member

When calling get_cmd_output_path() to create a directory via the plugin hpssm, sos threw the following exception:

Traceback (most recent call last):
File "/root/sos/sos/report/init.py", line 1224, in setup
plug.setup()
File "/root/sos/sos/report/plugins/hpssm.py", line 67, in setup
logpath = self.get_cmd_output_path()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/sos/sos/report/plugins/init.py", line 2168,
in get_cmd_output_path
os.makedirs(cmd_output_path)
File "", line 225, in makedirs
FileExistsError: [Errno 17] File exists:
'/var/tmp/sos.1gdy83zb/sosreport-localhost-vbwfnpn/sos_commands/hpssm'

This was happening because the directory 'hpssm' was already created. With this change we avoid any race where we call os.makedirs() after we have already created the plugin directory.

Closes: RHBZ #2216608


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname [email protected]?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?

When calling get_cmd_output_path() to create a directory
via the plugin hpssm, sos threw the following exception:

Traceback (most recent call last):
  File "/root/sos/sos/report/__init__.py", line 1224, in setup
    plug.setup()
  File "/root/sos/sos/report/plugins/hpssm.py", line 67, in setup
    logpath = self.get_cmd_output_path()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/sos/sos/report/plugins/__init__.py", line 2168,
	in get_cmd_output_path
    os.makedirs(cmd_output_path)
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists:
'/var/tmp/sos.1gdy83zb/sosreport-localhost-vbwfnpn/sos_commands/hpssm'

This was happening because the directory 'hpssm' was already created.
With this change we avoid any race where we call os.makedirs() after
we have already created the plugin directory.

Closes: RHBZ #2216608

Signed-off-by: Jose Castillo <[email protected]>
@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3285
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

Copy link
Contributor

@pmoravec pmoravec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. snap test failing is unrelated (there is a PR for it).

@arif-ali
Copy link
Member

ACK. snap test failing is unrelated (there is a PR for it).

I think the job never went through, someone with admin needs to restart that job ;)

@TurboTurtle
Copy link
Member

Seems Cirrus is having some issues, I'm restarting the jobs again. This looks perfectly fine, but I'm gonna play it safe and wait for the tests to pass before merge. Additionally, I think this is important for 4.5.5, which is supposed to close today. I mentioned this on IRC but I'll say it here too - I'm going to try and close out 4.5.5 later today but at the latest it will be tomorrow.

Copy link
Member

@arif-ali arif-ali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, lgtm :)

@TurboTurtle TurboTurtle merged commit c0865c1 into sosreport:main Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants