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

Fix exception being thrown for new instance registration with ELB #5506

Merged
merged 1 commit into from
Jan 27, 2014

Conversation

mohangk
Copy link
Contributor

@mohangk mohangk commented Jan 5, 2014

Currently if we are trying to register an instance that has not yet
been registered with the elb an exception is thrown as follows:

Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 1412, in
main()
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 335, in main
elb_man.register(wait, enable_availability_zone)
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 168, in register
self._await_elb_instance_state(lb, 'InService', initial_state)
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 213, in _await_elb_instance_state
if instance_state.state != initial_state.state:
AttributeError: 'NoneType' object has no attribute 'state'

This is expected because the code is querying the elb for the state of the new instance and it responds with a "InvalidInstance" response (as its not been registered with the ELB yet) and the code sets the value of the initial_state to None.

This code change checks if the initial_state is None. If it is, its safe to assume that its state has changed.

Currently if we are trying to register an instance that has not yet
been registered with the elb an exception is thrown.
@jctanner
Copy link
Contributor

@mohangk I think your patch will work, but I would prefer to prevent the exception by using hasattr() on the object.

jctanner added a commit that referenced this pull request Jan 27, 2014
Fix exception being thrown for new instance registration with ELB
@jctanner jctanner merged commit b8d3c0f into ansible:devel Jan 27, 2014
@mohangk mohangk deleted the fix_elb_register_new_instance branch January 28, 2014 01:23
@mohangk
Copy link
Contributor Author

mohangk commented Jan 28, 2014

Thanks!

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. cloud
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants