From 763c733a912c0784e64507b71135688c4be49acf Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 14 Apr 2015 22:11:42 +0200 Subject: [PATCH] feature #3654: Recover EPILOG states with retry --- src/dm/DispatchManagerActions.cc | 14 +- src/lcm/LifeCycleActions.cc | 142 +++++++-------------- src/lcm/LifeCycleStates.cc | 1 + src/oca/ruby/opennebula/virtual_machine.rb | 2 +- 4 files changed, 53 insertions(+), 106 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index f25160296d..b44791792f 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -236,8 +236,7 @@ int DispatchManager::shutdown ( if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::RUNNING || - vm->get_lcm_state() == VirtualMachine::UNKNOWN || - vm->get_lcm_state() == VirtualMachine::EPILOG_FAILURE)) + vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); @@ -285,8 +284,7 @@ int DispatchManager::undeploy( if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::RUNNING || - vm->get_lcm_state() == VirtualMachine::UNKNOWN || - vm->get_lcm_state() == VirtualMachine::EPILOG_UNDEPLOY_FAILURE)) + vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); @@ -483,9 +481,8 @@ int DispatchManager::stop( oss << "Stopping VM " << vid; NebulaLog::log("DiM",Log::DEBUG,oss); - if (vm->get_state() == VirtualMachine::ACTIVE && - (vm->get_lcm_state() == VirtualMachine::RUNNING || - vm->get_lcm_state() == VirtualMachine::EPILOG_STOP_FAILURE)) + if (vm->get_state() == VirtualMachine::ACTIVE && + vm->get_lcm_state() == VirtualMachine::RUNNING ) { Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); @@ -531,8 +528,7 @@ int DispatchManager::cancel( if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::RUNNING || - vm->get_lcm_state() == VirtualMachine::UNKNOWN || - vm->get_lcm_state() == VirtualMachine::EPILOG_FAILURE)) + vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 01098eaca7..9df6e2013a 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -176,13 +176,7 @@ void LifeCycleManager::suspend_action(int vid) void LifeCycleManager::stop_action(int vid) { - Nebula& nd = Nebula::instance(); - VirtualMachineManager * vmm = nd.get_vmm(); - TransferManager * tm = nd.get_tm(); - - VirtualMachine * vm; - - vm = vmpool->get(vid,true); + VirtualMachine * vm = vmpool->get(vid,true); if ( vm == 0 ) { @@ -192,6 +186,9 @@ void LifeCycleManager::stop_action(int vid) if (vm->get_state() == VirtualMachine::ACTIVE && vm->get_lcm_state() == VirtualMachine::RUNNING) { + Nebula& nd = Nebula::instance(); + VirtualMachineManager * vmm = nd.get_vmm(); + //---------------------------------------------------- // SAVE_STOP STATE //---------------------------------------------------- @@ -212,23 +209,6 @@ void LifeCycleManager::stop_action(int vid) vmm->trigger(VirtualMachineManager::SAVE,vid); } - else if (vm->get_state() == VirtualMachine::ACTIVE && - vm->get_lcm_state() == VirtualMachine::EPILOG_STOP_FAILURE) - { - //---------------------------------------------------- - // Bypass SAVE_STOP - //---------------------------------------------------- - - vm->set_state(VirtualMachine::EPILOG_STOP); - - vmpool->update(vm); - - vm->log("LCM", Log::INFO, "New VM state is EPILOG_STOP"); - - //---------------------------------------------------- - - tm->trigger(TransferManager::EPILOG_STOP,vid); - } else { vm->log("LCM", Log::ERROR, "stop_action, VM in a wrong state."); @@ -412,13 +392,7 @@ void LifeCycleManager::live_migrate_action(int vid) void LifeCycleManager::shutdown_action(int vid) { - VirtualMachine * vm; - - Nebula& nd = Nebula::instance(); - VirtualMachineManager * vmm = nd.get_vmm(); - TransferManager * tm = nd.get_tm(); - - vm = vmpool->get(vid,true); + VirtualMachine * vm = vmpool->get(vid,true); if ( vm == 0 ) { @@ -429,6 +403,9 @@ void LifeCycleManager::shutdown_action(int vid) (vm->get_lcm_state() == VirtualMachine::RUNNING || vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { + Nebula& nd = Nebula::instance(); + VirtualMachineManager * vmm = nd.get_vmm(); + //---------------------------------------------------- // SHUTDOWN STATE //---------------------------------------------------- @@ -449,23 +426,6 @@ void LifeCycleManager::shutdown_action(int vid) vmm->trigger(VirtualMachineManager::SHUTDOWN,vid); } - else if (vm->get_state() == VirtualMachine::ACTIVE && - vm->get_lcm_state() == VirtualMachine::EPILOG_FAILURE) - { - //---------------------------------------------------- - // Bypass SHUTDOWN - //---------------------------------------------------- - - vm->set_state(VirtualMachine::EPILOG); - - vmpool->update(vm); - - vm->log("LCM", Log::INFO, "New VM state is EPILOG"); - - //---------------------------------------------------- - - tm->trigger(TransferManager::EPILOG,vid); - } else { vm->log("LCM", Log::ERROR, "shutdown_action, VM in a wrong state."); @@ -481,13 +441,7 @@ void LifeCycleManager::shutdown_action(int vid) void LifeCycleManager::undeploy_action(int vid, bool hard) { - Nebula& nd = Nebula::instance(); - VirtualMachineManager * vmm = nd.get_vmm(); - TransferManager * tm = nd.get_tm(); - - VirtualMachine * vm; - - vm = vmpool->get(vid,true); + VirtualMachine * vm = vmpool->get(vid,true); if ( vm == 0 ) { @@ -498,6 +452,9 @@ void LifeCycleManager::undeploy_action(int vid, bool hard) (vm->get_lcm_state() == VirtualMachine::RUNNING || vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { + Nebula& nd = Nebula::instance(); + VirtualMachineManager * vmm = nd.get_vmm(); + //---------------------------------------------------- // SHUTDOWN_UNDEPLOY STATE //---------------------------------------------------- @@ -527,23 +484,6 @@ void LifeCycleManager::undeploy_action(int vid, bool hard) vmpool->update_history(vm); } - else if (vm->get_state() == VirtualMachine::ACTIVE && - vm->get_lcm_state() == VirtualMachine::EPILOG_UNDEPLOY_FAILURE) - { - //---------------------------------------------------- - // Bypass SHUTDOWN_UNDEPLOY - //---------------------------------------------------- - - vm->set_state(VirtualMachine::EPILOG_UNDEPLOY); - - vmpool->update(vm); - - vm->log("LCM", Log::INFO, "New VM state is EPILOG_UNDEPLOY"); - - //---------------------------------------------------- - - tm->trigger(TransferManager::EPILOG_STOP,vid); - } else { vm->log("LCM", Log::ERROR, "undeploy_action, VM in a wrong state."); @@ -694,13 +634,7 @@ void LifeCycleManager::restore_action(int vid) void LifeCycleManager::cancel_action(int vid) { - VirtualMachine * vm; - - Nebula& nd = Nebula::instance(); - VirtualMachineManager * vmm = nd.get_vmm(); - TransferManager * tm = nd.get_tm(); - - vm = vmpool->get(vid,true); + VirtualMachine * vm = vmpool->get(vid,true); if ( vm == 0 ) { @@ -711,6 +645,9 @@ void LifeCycleManager::cancel_action(int vid) (vm->get_lcm_state() == VirtualMachine::RUNNING || vm->get_lcm_state() == VirtualMachine::UNKNOWN)) { + Nebula& nd = Nebula::instance(); + VirtualMachineManager * vmm = nd.get_vmm(); + //---------------------------------------------------- // CANCEL STATE //---------------------------------------------------- @@ -731,23 +668,6 @@ void LifeCycleManager::cancel_action(int vid) vmm->trigger(VirtualMachineManager::CANCEL,vid); } - else if (vm->get_state() == VirtualMachine::ACTIVE && - vm->get_lcm_state() == VirtualMachine::EPILOG_FAILURE) - { - //---------------------------------------------------- - // Bypass CANCEL - //---------------------------------------------------- - - vm->set_state(VirtualMachine::EPILOG); - - vmpool->update(vm); - - vm->log("LCM", Log::INFO, "New VM state is EPILOG"); - - //---------------------------------------------------- - - tm->trigger(TransferManager::EPILOG,vid); - } else { vm->log("LCM", Log::ERROR, "cancel_action, VM in a wrong state."); @@ -827,6 +747,36 @@ void LifeCycleManager::retry_action(int vid) tm->trigger(TransferManager::PROLOG,vid); break; + case VirtualMachine::EPILOG_FAILURE: + vm->set_state(VirtualMachine::EPILOG); + + vmpool->update(vm); + + vm->log("LCM", Log::INFO, "New VM state is EPILOG"); + + tm->trigger(TransferManager::EPILOG,vid); + break; + + case VirtualMachine::EPILOG_STOP_FAILURE: + vm->set_state(VirtualMachine::EPILOG_STOP); + + vmpool->update(vm); + + vm->log("LCM", Log::INFO, "New VM state is EPILOG_STOP"); + + tm->trigger(TransferManager::EPILOG_STOP,vid); + break; + + case VirtualMachine::EPILOG_UNDEPLOY_FAILURE: + vm->set_state(VirtualMachine::EPILOG_UNDEPLOY); + + vmpool->update(vm); + + vm->log("LCM", Log::INFO, "New VM state is EPILOG_UNDEPLOY"); + + tm->trigger(TransferManager::EPILOG_STOP,vid); + break; + case VirtualMachine::LCM_INIT: case VirtualMachine::BOOT: case VirtualMachine::BOOT_MIGRATE: diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index f9500a825a..03243ba0ba 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -901,6 +901,7 @@ void LifeCycleManager::epilog_success_action(int vid) state = vm->get_lcm_state(); + //Recover failure epilog states with success if ( state == VirtualMachine::EPILOG_STOP_FAILURE ) { vm->set_state(VirtualMachine::EPILOG_STOP); diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index f3accbcbb6..1e3c34fc3c 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -150,7 +150,7 @@ module OpenNebula "PROLOG_FAILURE" => "fail", "EPILOG_FAILURE" => "fail", "EPILOG_STOP_FAILURE" => "fail", - "EPILOG_UNDEPLOY_FAILURE" => "fail", + "EPILOG_UNDEPLOY_FAILURE" => "fail" } MIGRATE_REASON=%w{NONE ERROR USER}