Skip to content

Commit

Permalink
B OpenNebula#3175 Fix container shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Apr 3, 2019
1 parent a975508 commit bd341df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
23 changes: 19 additions & 4 deletions src/vmm_mad/remotes/lib/lxd/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,25 @@ def stop(options = { :timeout => 120 })
def check_stop
return if status != 'Running'

if ARGV[-1] == '-f'
stop(:force => true)
else
stop
begin
if ARGV[-1] == '-f'
stop(:force => true)
else
stop
end
rescue => exception
OpenNebula.log_error exception

2.times do
# This call may return an operation output instead of a
# container data in case of timeout. The call breaks
# the container attributes. It needs to be read again
container = Container.get(vm_name, xml, client)

break if %w[Running Stopped].include? container.status
end

container.stop(:force => true) if container.status == 'Running'
end
end

Expand Down
26 changes: 6 additions & 20 deletions src/vmm_mad/remotes/lxd/shutdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,12 @@ container = Container.get(vm_name, xml, client)
# ------------------------------------------------------------------------------
# Stop the container & unmap devices if not a wild container
# ------------------------------------------------------------------------------
begin
container.check_stop
rescue => exception
OpenNebula.log_error exception
end

# This call may return an operation output instead of a container data
# in case of timeout. The call breaks the container attributes
# it needs to be read again
container = Container.get(vm_name, xml, client) # :status => "Sucess"
# Fixer call
container = Container.get(vm_name, xml, client) unless %w[Running Stopped].include? container.status

if !container.wild?
container.stop(:force => true) if container.status == 'Running'
container.vnc('stop')
container.check_stop

e = 'Failed to dismantle container storage'
raise "#{e}\n#{container}" unless container.setup_storage('unmap')
return if container.wild?

container.delete
end
raise 'Failed to dismantle container storage' unless \
container.setup_storage('unmap')

container.vnc('stop')
container.delete

0 comments on commit bd341df

Please sign in to comment.