Limit elastic IP association to pending, running instances #188
Conversation
EC2 takes some time to clean up terminated instances. When replacing an instance, elastic association on the new instance often fails because the old instance is still hanging around in a "terminated" state. This change limits instance lookup to pending or running instances for the purpose of elastic IP association.
Wouldn't it be more sensible to disassociate the elastic IP from the instance when terminating, so it can be re-used quicker? Or am I totally on the wrong boat here? |
This is a problem even if the terminated instance never had the elastic IP. The requirements are simply that you have two instances with the same name, one of which is in the "terminated" state. I've only seen that while replacing an instance (and AWS hasn't yet cleaned up the terminated instance), so I used that case as an example. The general problem is that it never makes sense to associate an elastic IP with anything other than a pending or running instance, so the query should only consider those. |
Ah, so the problem is not that AWS rejects the configuration, but that puppet detects the elastic IP on the terminated instance and complains? |
It tries to associate the IP with the terminated instance, and fails. I've been running with my patch so I haven't seen this error lately, but I can try and recreate it later today and paste the output. I'm not sure why I didn't do that when I filed this issue a few months back. |
The most frustrating part was that it only failed some of the time. When there are multiple matching instances Puppet just grabs the first instance in the set. If that happened to be the 'running' instance, there was no issue. If it was the 'terminated' instance, it blew up. |
Here's a pretty minimal case:
Instead of ignoring the terminated instance(s),
|
This is the same as my issue with autoscaling instances with the same name. Please see #164 An instance can terminate but still is not actually cleaned up for a bit in AWS. If it has the same name as the new autoscaled node, it will fail. |
Limit elastic IP association to pending, running instances
EC2 takes some time to clean up terminated instances. When replacing an instance, elastic IP association on the new instance often fails because the old instance is still hanging around in a "terminated" state.
This change limits instance lookup to pending or running instances for the purpose of elastic IP association.