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

B #2629 Prevent race-condition when spawning multiple VMs

This commit is contained in:
Jan Orel 2019-01-18 15:44:44 +01:00 committed by Ruben S. Montero
parent 24af2b77d2
commit 3ed4ede17d
3 changed files with 6 additions and 4 deletions

View File

@ -75,11 +75,11 @@ module OpenNebula
# Executes a command, if it fails returns error message and exits
# If a second parameter is present it is used as the error message when
# the command fails
def self.exec_and_log(command, message=nil)
def self.exec_and_log(command, message=nil, allowed_return_code=0)
output=`#{command} 2>&1 1>/dev/null`
code=$?.exitstatus
if code!=0
if code!=0 && code!=allowed_return_code
log_error "Command \"#{command}\" failed."
log_error output
if !message

View File

@ -391,7 +391,7 @@ private
def create_bridge
return if @bridges.keys.include? @nic[:bridge]
OpenNebula.exec_and_log("#{command(:ovs_vsctl)} add-br #{@nic[:bridge]}")
OpenNebula.exec_and_log("#{command(:ovs_vsctl)} --may-exist add-br #{@nic[:bridge]}")
set_bridge_options

View File

@ -65,9 +65,11 @@ module VXLAN
ip_link_conf << "#{option} #{value} "
end
# `ip link add ...` returns 2 when vxlan device already exists
# allow it to prevent race conditions
OpenNebula.exec_and_log("#{command(:ip)} link add #{@nic[@attr_vlan_dev]}"\
" #{mtu} type vxlan id #{@nic[@attr_vlan_id]} #{group} #{ttl}"\
" #{tep} #{ip_link_conf}")
" #{tep} #{ip_link_conf}", nil, 2)
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[@attr_vlan_dev]} up")
end