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

F #1684: Fix shutdown timeout handling (#2975)

This commit is contained in:
Daniel Clavijo Coca 2019-02-21 01:48:17 -06:00 committed by Ruben S. Montero
parent 5dd2353507
commit 4a97c51329
2 changed files with 19 additions and 11 deletions

View File

@ -185,11 +185,6 @@ class Container
def stop(options = { :timeout => 120 })
change_state(__method__, options)
rescue StandardError => exception
raise exception unless exception.class == Net::ReadTimeout
OpenNebula.log_error "Timeout detected\n#{exception}\nForcing shutdown"
stop(:force => true)
end
def restart(options = {})

View File

@ -36,15 +36,28 @@ container = Container.get(vm_name, xml, client)
# ------------------------------------------------------------------------------
# Stop the container & unmap devices if not a wild container
# ------------------------------------------------------------------------------
if ARGV[-1] == '-f'
container.stop(:force => true)
else
container.stop
begin
if ARGV[-1] == '-f'
container.stop(:force => true)
else
container.stop
end
rescue => exception
OpenNebula.log_error exception
end
if !container.wild?
unmapped = container.setup_storage('unmap')
raise 'Failed to dismantle container storage' unless unmapped
# 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"
container = Container.get(vm_name, xml, client) unless %w[Running Stopped].include? container.status
container.stop(:force => true) if container.status == 'Running'
e = 'Failed to dismantle container storage'
raise "#{e}\n#{container}" unless container.setup_storage('unmap')
container.delete
end