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

Ensure SystemExit is captured on driver initialization #3230

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Sep 5, 2021

Prevent a broken driver from affecting usability of molecule by catching even SystemExit.

Related: ansible-community/molecule-podman#81

Prevent a broken driver from affecting usability of molecule by
catching even SystemExit.

Related: ansible-community/molecule-podman#81
@ssbarnea ssbarnea merged commit 5e717ce into main Sep 6, 2021
@ssbarnea ssbarnea deleted the fix/broken-drivers branch September 6, 2021 07:43
@@ -51,14 +51,14 @@ def drivers(config=None) -> UserListMap:
pm = pluggy.PluginManager("molecule.driver")
try:
pm.load_setuptools_entrypoints("molecule.driver")
except Exception:
except (Exception, SystemExit):
Copy link
Member

Choose a reason for hiding this comment

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

@ssbarnea this doesn't catch everything, though. Is it intentional that you didn't use BaseException?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure what kind of other exceptions would Base Exception catch so I went for that approach. Shortly I don't know if current code is better than just BaseException or not.

Copy link
Member

Choose a reason for hiding this comment

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

You could catch all the exceptions excluding KeyboardInterrupt, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

OTOH Molecule could also define own exceptions for communicating misconfiguration clearly. In this case, you'd need something like

try:
    ...
except KeyboardInterrupt:
    raise
except MoleculeMisconfiguredException:
    report_exc()
except BaseException:
    process_exc()

tadeboro pushed a commit that referenced this pull request Oct 1, 2021
Prevent a broken driver from affecting usability of molecule by
catching even SystemExit.

Related: ansible-community/molecule-podman#81
@patchback

This comment has been minimized.

@patchback
Copy link

patchback bot commented Oct 1, 2021

Backport to stable/3.4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable/3.4/5e717ce98431b7432e55310afcc205b382249319/pr-3230

Backported as #3253

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 1, 2021
Prevent a broken driver from affecting usability of molecule by
catching even SystemExit.

Related: ansible-community/molecule-podman#81
(cherry picked from commit 5e717ce)
webknjaz pushed a commit that referenced this pull request Oct 2, 2021
Prevent a broken driver from affecting usability of molecule by
catching even SystemExit.

Related: ansible-community/molecule-podman#81
(cherry picked from commit 5e717ce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants