Fix exception being thrown for new instance registration with ELB #5506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.