1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Feature #3654: Add new transtions to recover failed VM boot

This commit is contained in:
Carlos Martín 2015-03-20 17:53:55 +01:00
parent 42259dc87d
commit 39c0686c99
4 changed files with 106 additions and 24 deletions

View File

@ -138,7 +138,10 @@ public:
SHUTDOWN_UNDEPLOY = 29,
EPILOG_UNDEPLOY = 30,
PROLOG_UNDEPLOY = 31,
BOOT_UNDEPLOY = 32
BOOT_UNDEPLOY = 32,
BOOT_MIGRATE = 33,
BOOT_FAILURE = 34,
BOOT_MIGRATE_FAILURE= 35
};
static int lcm_state_from_str(string& st, LcmState& state)
@ -178,6 +181,9 @@ public:
else if ( st == "EPILOG_UNDEPLOY") { state = EPILOG_UNDEPLOY; }
else if ( st == "PROLOG_UNDEPLOY") { state = PROLOG_UNDEPLOY; }
else if ( st == "BOOT_UNDEPLOY") { state = BOOT_UNDEPLOY; }
else if ( st == "BOOT_MIGRATE") { state = BOOT_MIGRATE; }
else if ( st == "BOOT_FAILURE") { state = BOOT_FAILURE; }
else if ( st == "BOOT_MIGRATE_FAILURE") { state = BOOT_MIGRATE_FAILURE; }
else {return -1;}
return 0;
@ -220,6 +226,9 @@ public:
case EPILOG_UNDEPLOY: st = "EPILOG_UNDEPLOY"; break;
case PROLOG_UNDEPLOY: st = "PROLOG_UNDEPLOY"; break;
case BOOT_UNDEPLOY: st = "BOOT_UNDEPLOY"; break;
case BOOT_MIGRATE: st = "BOOT_MIGRATE"; break;
case BOOT_FAILURE: st = "BOOT_FAILURE"; break;
case BOOT_MIGRATE_FAILURE: st = "BOOT_MIGRATE_FAILURE"; break;
}
return st;

View File

@ -687,7 +687,10 @@ int DispatchManager::restart(int vid)
vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();

View File

@ -706,34 +706,79 @@ void LifeCycleManager::restart_action(int vid)
vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE))
||vm->get_state() == VirtualMachine::POWEROFF)
{
Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm();
VirtualMachineManager::Actions action;
//----------------------------------------------------
// RE-START THE VM IN THE SAME HOST
//----------------------------------------------------
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::BOOT ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
if (vm->get_state() == VirtualMachine::ACTIVE)
{
vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
}
else if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::UNKNOWN)
{
vm->set_state(VirtualMachine::BOOT_UNKNOWN);
switch (vm->get_lcm_state()) {
case VirtualMachine::BOOT:
case VirtualMachine::BOOT_UNKNOWN:
case VirtualMachine::BOOT_POWEROFF:
action = VirtualMachineManager::DEPLOY;
vmpool->update(vm);
vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
vm->log("LCM", Log::INFO, "New VM state is BOOT_UNKNOWN");
break;
case VirtualMachine::BOOT_SUSPENDED:
case VirtualMachine::BOOT_STOPPED:
case VirtualMachine::BOOT_UNDEPLOY:
case VirtualMachine::BOOT_MIGRATE:
action = VirtualMachineManager::RESTORE;
vm->log("LCM", Log::INFO, "Sending RESTORE command to VM again");
break;
case VirtualMachine::UNKNOWN:
action = VirtualMachineManager::DEPLOY;
vm->set_state(VirtualMachine::BOOT_UNKNOWN);
vmpool->update(vm);
vm->log("LCM", Log::INFO, "New VM state is BOOT_UNKNOWN");
break;
case VirtualMachine::BOOT_FAILURE:
action = VirtualMachineManager::DEPLOY;
vm->set_state(VirtualMachine::BOOT);
vmpool->update(vm);
vm->log("LCM", Log::INFO, "New VM state is BOOT");
break;
case VirtualMachine::BOOT_MIGRATE_FAILURE:
action = VirtualMachineManager::RESTORE;
vm->set_state(VirtualMachine::BOOT_MIGRATE);
vmpool->update(vm);
vm->log("LCM", Log::INFO, "New VM state is BOOT_MIGRATE");
break;
default:
break;
}
}
else // if ( vm->get_state() == VirtualMachine::POWEROFF )
{
@ -757,7 +802,7 @@ void LifeCycleManager::restart_action(int vid)
vm->log("LCM", Log::INFO, "New VM state is BOOT_POWEROFF");
}
vmm->trigger(VirtualMachineManager::DEPLOY,vid);
vmm->trigger(action,vid);
}
else
{
@ -971,6 +1016,9 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
case VirtualMachine::BOOT_SUSPENDED:
case VirtualMachine::BOOT_STOPPED:
case VirtualMachine::BOOT_UNDEPLOY:
case VirtualMachine::BOOT_MIGRATE:
case VirtualMachine::BOOT_FAILURE:
case VirtualMachine::BOOT_MIGRATE_FAILURE:
case VirtualMachine::RUNNING:
case VirtualMachine::UNKNOWN:
case VirtualMachine::SHUTDOWN:
@ -1168,6 +1216,9 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
case VirtualMachine::BOOT_STOPPED:
case VirtualMachine::BOOT_UNDEPLOY:
case VirtualMachine::MIGRATE:
case VirtualMachine::BOOT_MIGRATE:
case VirtualMachine::BOOT_MIGRATE_FAILURE:
case VirtualMachine::BOOT_FAILURE:
if (success)
{
//Auto-generate deploy-id it'll work for Xen, KVM and VMware

View File

@ -308,7 +308,10 @@ void LifeCycleManager::deploy_success_action(int vid)
vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY )
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE )
{
vm->set_state(VirtualMachine::RUNNING);
@ -400,11 +403,23 @@ void LifeCycleManager::deploy_failure_action(int vid)
vmm->trigger(VirtualMachineManager::POLL,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT)
else if (vm->get_lcm_state() == VirtualMachine::BOOT ||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE)
{
vm->set_running_etime(the_time);
vm->set_state(VirtualMachine::BOOT_FAILURE);
failure_action(vm);
vmpool->update(vm);
vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is BOOT_FAILURE");
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE )
{
vm->set_state(VirtualMachine::BOOT_MIGRATE_FAILURE);
vmpool->update(vm);
vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is BOOT_MIGRATE_FAILURE");
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN)
{
@ -716,7 +731,11 @@ void LifeCycleManager::prolog_success_action(int vid)
{
vm->set_state(VirtualMachine::BOOT_UNDEPLOY);
}
else // PROLOG || PROLOG_MIGRATE
else if ( lcm_state == VirtualMachine::PROLOG_MIGRATE )
{
vm->set_state(VirtualMachine::BOOT_MIGRATE);
}
else // PROLOG
{
vm->set_state(VirtualMachine::BOOT);
}