From a3ef8a0375db2e2ebaed3e64d5930b31921e7db3 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 9 Oct 2014 16:23:12 +0200 Subject: [PATCH] bug #3212: Only move VMs to poweroff it they have been successfully monitored at least once. --- src/im/MonitorThread.cc | 4 +--- src/lcm/LifeCycleActions.cc | 4 ++++ src/lcm/LifeCycleStates.cc | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/im/MonitorThread.cc b/src/im/MonitorThread.cc index 82cd1b6d33..082d354c19 100644 --- a/src/im/MonitorThread.cc +++ b/src/im/MonitorThread.cc @@ -194,8 +194,6 @@ void MonitorThread::do_message() return; } - time_t prev_last_monitor = host->get_last_monitored(); - rc = host->update_info(tmpl, vm_poll, lost, found, non_shared_ds, reserved_cpu, reserved_mem); @@ -241,7 +239,7 @@ void MonitorThread::do_message() // 3.- It has been monitored at least once if (vm->hasHistory() && vm->get_lcm_state() == VirtualMachine::RUNNING && - prev_last_monitor <= vm->get_last_poll() ) + vm->get_last_poll() != 0) { lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, *its); } diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 55ec3fc06a..69402af3df 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -612,6 +612,8 @@ void LifeCycleManager::restore_action(int vid) vm->set_stime(the_time); + vm->set_last_poll(0); + vm->set_running_stime(the_time); vmpool->update_history(vm); @@ -746,6 +748,8 @@ void LifeCycleManager::restart_action(int vid) vm->set_stime(the_time); + vm->set_last_poll(0); + vm->set_running_stime(the_time); vmpool->update_history(vm); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index b70ebd7d7a..eba86cf0f4 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -208,6 +208,8 @@ void LifeCycleManager::save_failure_action(int vid) vm->set_running_stime(the_time); + vm->set_last_poll(0); + vmpool->update_history(vm); vm->log("LCM", Log::INFO, "Fail to save VM state while migrating." @@ -275,6 +277,8 @@ void LifeCycleManager::deploy_success_action(int vid) vm->set_running_stime(the_time); + vm->set_last_poll(0); + vmpool->update_history(vm); vm->set_previous_etime(the_time); @@ -383,6 +387,8 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_running_stime(the_time); + vm->set_last_poll(0); + vmpool->update_history(vm); vm->log("LCM", Log::INFO, "Fail to live migrate VM." @@ -713,6 +719,8 @@ void LifeCycleManager::prolog_success_action(int vid) vm->set_running_stime(the_time); + vm->set_last_poll(0); + vmpool->update_history(vm); vm->log("LCM", Log::INFO, "New VM state is BOOT"); @@ -1348,6 +1356,8 @@ void LifeCycleManager::monitor_poweron_action(int vid) vm->set_running_stime(the_time); + vm->set_last_poll(0); + vmpool->update_history(vm); vm->log("LCM", Log::INFO, "New VM state is RUNNING");