1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

B #5345: Fix elastic IP assignment (#1134)

Allow to be already assigned on host, e.g:
when VM poweroff itself and then resumes
This commit is contained in:
Jan Orel 2021-04-29 17:26:16 +02:00 committed by GitHub
parent b03efb08ae
commit 85d66f3938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -73,7 +73,7 @@ class ElasticDriver < VNMMAD::VNMDriver
process_all do |nic|
next if attach_nic_id && attach_nic_id != nic[:nic_id]
cmds.add :ip, "route add #{nic[:ip]}/32 dev #{nic[:bridge]}"
cmds.add :ip, "route add #{nic[:ip]}/32 dev #{nic[:bridge]} ||:"
cmds.add :ip, "neighbour add proxy #{nic[:gateway]} dev #{nic[:bridge]}"
provider.activate(cmds, nic) if provider.respond_to? :activate

View File

@ -55,6 +55,12 @@ class PacketProvider
def assign(_ip, external, _opts = {})
@client.assign_cidr_device("#{external}/32", @deploy_id)
0
rescue Packet::Error => e
# potential VM poweroff(itself) + resume
return 0 if e.message == '{"errors"=>["Address has already been taken"]}'
OpenNebula.log_error("Error assiging #{external}:#{e.message}")
1
rescue StandardError => e
OpenNebula.log_error("Error assiging #{external}:#{e.message}")
1
@ -87,4 +93,5 @@ class PacketProvider
cmds.add :iptables, "-t nat -D PREROUTING -d #{nic[:external_ip]} -j DNAT"\
" --to-destination #{nic[:ip]}"
end
end