Check spot instance is running before trying to attach volumes #12459
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, given the following manifest snippet:
According to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-limits.html the Amazon API does not honour the encryption setting on additional volumes. This could be worked around with something like:
However waiting for the spot request to be fulfilled does not guarantee that the instance is running; quite often it's pending for ~ 30-40 seconds which causes the volume attachment to fail. This PR makes the volume attachment poll the instance API to ensure it's running before attempting to attach and fixes the issue.
I lifted the whole
resource.StateChangeConf
block from theaws_instance
resource rather than write a copy of the same refresh function.I have to include the following disclaimer to keep my employers legal team happy: