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
ec2_elb_lb fix/add useful exception handling to _create_elb_listeners #35994
ec2_elb_lb fix/add useful exception handling to _create_elb_listeners #35994
Conversation
The test
The test
|
self.changed = self.elb_conn.create_load_balancer_listeners(self.name, | ||
complex_listeners=listeners) | ||
except IndexError as e: | ||
self.module.fail_json(msg='unable to create listener for port 443 HTTPS without specifying an SSL cert: %s' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to hardcode the port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg='unable to create listener for HTTPS without specifying an SSL cert: %s'
Is that better?
complex_listeners=listeners) | ||
except IndexError as e: | ||
self.module.fail_json(msg='unable to create listener for port 443 HTTPS without specifying an SSL cert: %s' | ||
% e.message, exception=traceback.format_exc()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.message doesn't exist on Python 3 so this may raise an AttributeError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work out what I need to do with this instead then, I kinda didn't even think about the different python versions when I wrote this, my mistake.
True if succeeds | ||
|
||
Raises: | ||
IndexError: If HTTPS is specified as a listener but SSL cert is not specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically these docs aren't quite right. This doesn't raise IndexError - it catches an IndexError and then calls fail_json
itself, so callers don't need to also catch IndexError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh ok righto then, yeah now that you explain it like that I feel kinda stupid haha. Sorry about that, trying to make it clean has probably resulted in me trying to hard on this PR. So because it doesn't Raise the error, I should just remove the Raises section and leave the docstring as is? Or should I replace it with a Catch section? Sorry for the 50 questions here.
SUMMARY
Ran into an issue the other day whilst creating some ELBs and the exception messages seemed barely related to the actual problem so I've add some hopefully more useful exception handling. I've named it a fix but in reality I'm not sure what you'd call this, first PR so sorry if I've gotten anything wrong here.
ISSUE TYPE
COMPONENT NAME
ec2_elb_lb
ANSIBLE VERSION
ADDITIONAL INFORMATION