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

mail: Fix regression when sending mail without SSL (v2.7) #47019

Merged
merged 2 commits into from
Oct 22, 2018

Conversation

dagwieers
Copy link
Contributor

@dagwieers dagwieers commented Oct 13, 2018

SUMMARY

When this module was refactored in #37098 the non-SSL use-case was broken.

The main cause is that we have no way to do integration tests for testing SMTP.

This is a back-port to v2.7 of #46403
This fixes #46673

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

mail

ANSIBLE VERSION

v2.7

When this module was refactored in ansible#37098 the non-SSL use-case was broken.

The main cause is that we have no way to do integration tests for testing SMTP.

This is a back-port to v2.7 of ansible#46403
@dagwieers dagwieers added the affects_2.7 This issue/PR affects Ansible v2.7 label Oct 13, 2018
@dagwieers dagwieers requested a review from bcoca October 13, 2018 23:47
@webknjaz
Copy link
Member

Is this also in devel?

@@ -255,6 +255,8 @@ def main():
if secure == 'always':
module.fail_json(rc=1, msg='Unable to start an encrypted session to %s:%s: %s' %
(host, port, to_native(e)), exception=traceback.format_exc())
except:
pass
Copy link
Member

Choose a reason for hiding this comment

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

I'd do some debug logging in here. Swallowing wholesale exceptions like this is harmful. Let's at least do except Exception as exc: and add log that + I'd like to see an explicit section for that socket error as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole purpose here is that it falls back to the second attempt, except if secure == always.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but it's untrackable this way. Also, there's too much nesting in here. It's hard to reason about it. It's better for maintainability to set explicit expectations for what we want to ignore.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should never use a bare except in code. except Exception is acceptable when it is a catchall case (like this). bare except catches things like KeyboardInterrupt and SystemExit which we do not want to catch in 99% of circumstances. In the other 1%, we should be explicit about catching those exceptions so that people can tell we know what we're doing. (Changing to except Exception isn't sufficient to block this as a backport, though. I'm going to merge this and the change can be made in devel).

@dagwieers
Copy link
Contributor Author

This is a back-port to v2.7 of #46403

@webknjaz
Copy link
Member

Oh, why doesn't it include docs fixes? Why is it partial?

@dagwieers
Copy link
Contributor Author

Because the regression is in those 2 lines, not the documentation.

@ansibot
Copy link
Contributor

ansibot commented Oct 14, 2018

Hi @dagwieers, thank you for submitting this pull-request!

click here for bot help

@ansibot ansibot added backport This PR does not target the devel branch. bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) small_patch support:community This issue/PR relates to code supported by the Ansible community. labels Oct 14, 2018
@abadger
Copy link
Contributor

abadger commented Oct 15, 2018

Mmm... before merging, though, this needs a changelog fragment. I can merge after that is added.

@webknjaz
Copy link
Member

webknjaz commented Oct 16, 2018

Pro tip: @abadger, you can actually do it yourself (via UI) at https://github.com/dagwieers/ansible/new/mail-regression27/changelogs/fragments if that's faster :)

@abadger
Copy link
Contributor

abadger commented Oct 16, 2018

@webknjaz yep, i know that i can fix up prs several ways. But that only helps if i know what should be in the changelog. Much better for the submitter to add the changelog since they know what it should say without asking around

@abadger abadger merged commit 44ae37d into ansible:stable-2.7 Oct 22, 2018
@abadger
Copy link
Contributor

abadger commented Oct 22, 2018

Merged for 2.7.1

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 backport This PR does not target the devel branch. bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) small_patch support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants