salt-cloud: Could not associate elastic ip address <None> with network interface <eni-xxxxxxxx>
This error occurs when creating a VM with AssociatePublicIpAddress: true once you have exhausted the number of VPC Elastic IPs you can allocate within a region.
Pull request #25315 which was incorporated in version 2015.8.0 changes the semantics of AssociatePublicIpAddress in a manner that I believe is incorrect. AssociatePublicIpAddress is now equivalent to associating an EIP to a network interface which according to salt-cloud documentation is incorrect:
base_ec2_vpc:
provider: my-ec2-southeast-public-ips
image: ami-a73264ce
size: m1.xlarge
ssh_username: ec2-user
script: /etc/salt/cloud.deploy.d/user_data.sh
network_interfaces:
- DeviceIndex: 0
PrivateIpAddresses:
- Primary: True
#auto assign public ip (not EIP)
AssociatePublicIpAddress: True
SubnetId: subnet-813d4bbf
SecurityGroupId:
- sg-750af413
There are obviously many use cases where one would like to auto-assign a public IP and not use an EIP which probably means that this change should be reverted.
A workaround that works in my setup is to modify the map_public_ip_on_launch subnet attribute for public subnets and remove AssociatePublicIpAddress from relevant salt-cloud profiles.
http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#modify_subnet_attribute-instance_method
@jgill Thanks for this report!
I just hit this, glad I'm not alone. I put a comment on commit 4d1fb4595b3c77c9311417d028262f9e7defb5a0. I applied this change manually on a salt-cloud 2015-8-1 installation, and it undid the regression (but probably broke again the thing the patch was intended to fix).
--- ec2.py.bak 2015-10-30 21:47:57.320000000 +0000
+++ ec2.py 2015-10-30 21:56:07.924000000 +0000
@@ -1221,13 +1221,9 @@
)
)
- associate_public_ip = interface.get('AssociatePublicIpAddress', False)
- if isinstance(associate_public_ip, str):
- # Assume id of EIP as value
- _associate_eip_with_interface(eni_id, associate_public_ip)
- elif interface.get('associate_eip'):
+ if interface.get('associate_eip'):
_associate_eip_with_interface(eni_id, interface.get('associate_eip'))
- elif interface.get('allocate_new_eip') or associate_public_ip:
+ elif interface.get('allocate_new_eip'):
_new_eip = _request_eip(interface)
_associate_eip_with_interface(eni_id, _new_eip)
elif interface.get('allocate_new_eips'):
@timcharper Thanks for posting this and commenting on the other commit. That will help track down the issue and hopefully solve this without breaking the other bug the patch was originally attempting to fix.
Thanks. I can't reproduce the bug the mentioned patch was intending to fix, and I'm allocating instances in VPCs, otherwise I would be sending you guys a pull request. Sorry I can't be more helpful.
If somebody can post a way to reproduce the original bug, I'd be willing to try and create a patch that solves both issues.
@timcharper I was testing this as well, and I also wasn't able to reproduce the original issue. I've submitted #28584 to restore pre-2015.8.0 behavior to using AssociatePublicIpAddress: True, which I think is the correct behavior for this setting.
If others disagree, we can circle back around to discuss it further.
FYI @jgill.