mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #1474: Synchronize cleanup operations and VM transition to PENDING. It uses the CLEANUP state to wait for delete actions to be completed.
This commit is contained in:
parent
1cc0e8d189
commit
70a10c37b7
@ -862,19 +862,30 @@ int DispatchManager::resubmit(int vid)
|
||||
break;
|
||||
|
||||
case VirtualMachine::FAILED: //Cleanup VM host files
|
||||
vm->log("DiM", Log::INFO, "New VM state is CLEANUP.");
|
||||
|
||||
vm->set_state(VirtualMachine::CLEANUP);
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
tm->trigger(TransferManager::EPILOG_DELETE,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOLD: // Move the VM to PENDING in any of these
|
||||
case VirtualMachine::STOPPED:
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
vm->set_state(VirtualMachine::PENDING);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->log("DiM", Log::INFO, "New VM state is PENDING.");
|
||||
break;
|
||||
|
||||
case VirtualMachine::ACTIVE: //Cleanup VM resources before PENDING
|
||||
lcm->trigger(LifeCycleManager::CLEAN,vid);
|
||||
lcm->trigger(LifeCycleManager::CLEAN, vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::DONE:
|
||||
NebulaLog::log("DiM",Log::ERROR,
|
||||
"Cannot resubmit a VM already in DONE state");
|
||||
|
@ -112,7 +112,7 @@ void LifeCycleManager::suspend_action(int vid)
|
||||
vm->set_state(VirtualMachine::SAVE_SUSPEND);
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is SAVE_SUSPEND");
|
||||
@ -156,9 +156,9 @@ void LifeCycleManager::stop_action(int vid)
|
||||
//----------------------------------------------------
|
||||
|
||||
vm->set_state(VirtualMachine::SAVE_STOP);
|
||||
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is SAVE_STOP");
|
||||
@ -600,8 +600,6 @@ void LifeCycleManager::clean_action(int vid)
|
||||
|
||||
clean_up_vm(vm);
|
||||
|
||||
dm->trigger(DispatchManager::RESUBMIT,vid);
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
|
||||
@ -621,6 +619,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm)
|
||||
VirtualMachine::LcmState state = vm->get_lcm_state();
|
||||
int vid = vm->get_oid();
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is CLEANUP.");
|
||||
|
||||
vm->set_state(VirtualMachine::CLEANUP);
|
||||
vm->set_resched(false);
|
||||
vmpool->update(vm);
|
||||
@ -730,7 +730,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm)
|
||||
vmpool->update_history(vm);
|
||||
tm->trigger(TransferManager::EPILOG_DELETE,vid);
|
||||
break;
|
||||
|
||||
|
||||
default: //LCM_INIT,CLEANUP
|
||||
break;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ void LifeCycleManager::deploy_failure_action(int vid)
|
||||
vm->set_reason(History::ERROR);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
|
||||
vm->set_previous_etime(the_time);
|
||||
|
||||
vm->set_previous_vm_info();
|
||||
@ -564,6 +564,7 @@ void LifeCycleManager::epilog_success_action(int vid)
|
||||
time_t the_time = time(0);
|
||||
int cpu,mem,disk;
|
||||
|
||||
VirtualMachine::LcmState state;
|
||||
DispatchManager::Actions action;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
@ -573,14 +574,24 @@ void LifeCycleManager::epilog_success_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
if (vm->get_lcm_state() == VirtualMachine::EPILOG_STOP)
|
||||
state = vm->get_lcm_state();
|
||||
|
||||
if ( state == VirtualMachine::EPILOG_STOP )
|
||||
{
|
||||
action = DispatchManager::STOP_SUCCESS;
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::EPILOG)
|
||||
else if ( state == VirtualMachine::EPILOG )
|
||||
{
|
||||
action = DispatchManager::DONE;
|
||||
}
|
||||
else if ( state == VirtualMachine::CLEANUP )
|
||||
{
|
||||
dm->trigger(DispatchManager::RESUBMIT, vid);
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"epilog_success_action, VM in a wrong state");
|
||||
@ -625,9 +636,19 @@ void LifeCycleManager::epilog_failure_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
vm->set_epilog_etime(the_time);
|
||||
if ( vm->get_lcm_state() == VirtualMachine::CLEANUP )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
DispatchManager * dm = nd.get_dm();
|
||||
|
||||
failure_action(vm);
|
||||
dm->trigger(DispatchManager::RESUBMIT, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->set_epilog_etime(the_time);
|
||||
|
||||
failure_action(vm);
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
@ -837,7 +858,7 @@ void LifeCycleManager::failure_action(VirtualMachine * vm)
|
||||
vm->set_state(VirtualMachine::FAILURE);
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_etime(the_time);
|
||||
|
@ -96,8 +96,7 @@ void TransferManagerDriver::protocol(
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::CLEANUP ||
|
||||
vm->get_lcm_state() == VirtualMachine::FAILURE ||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::FAILURE ||
|
||||
vm->get_lcm_state() == VirtualMachine::LCM_INIT )
|
||||
{
|
||||
os.str("");
|
||||
@ -128,6 +127,7 @@ void TransferManagerDriver::protocol(
|
||||
|
||||
case VirtualMachine::EPILOG:
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::CLEANUP:
|
||||
lcm_action = LifeCycleManager::EPILOG_SUCCESS;
|
||||
break;
|
||||
|
||||
@ -143,7 +143,7 @@ void TransferManagerDriver::protocol(
|
||||
|
||||
os.str("");
|
||||
os << "Error executing image transfer script";
|
||||
|
||||
|
||||
if (!info.empty() && info[0] != '-')
|
||||
{
|
||||
os << ": " << info;
|
||||
@ -151,7 +151,7 @@ void TransferManagerDriver::protocol(
|
||||
vm->set_template_error_message(os.str());
|
||||
vmpool->update(vm);
|
||||
}
|
||||
|
||||
|
||||
vm->log("TM",Log::ERROR,os);
|
||||
|
||||
switch (vm->get_lcm_state())
|
||||
@ -164,6 +164,7 @@ void TransferManagerDriver::protocol(
|
||||
|
||||
case VirtualMachine::EPILOG:
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::CLEANUP:
|
||||
lcm_action = LifeCycleManager::EPILOG_FAILURE;
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user