1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

Bug #3700: Transition from poff->runn requires the VM to be reported twice

This commit is contained in:
Carlos Martín 2015-04-30 17:11:05 +02:00
parent 7ad4bc9e9d
commit ea876146af
3 changed files with 41 additions and 3 deletions

View File

@ -165,6 +165,7 @@ public:
bool &with_vm_info,
set<int> &lost,
map<int,string> &found,
set<int> &found_twice,
const set<int> &non_shared_ds,
long long reserved_cpu,
long long reserved_mem);
@ -527,6 +528,12 @@ private:
*/
set<int> tmp_zombie_vms;
/**
* Tmp set of found VM IDs. Used to give recovered poweroff VMs one
* grace cycle, in case they reappear in outdated poll info.
*/
set<int> tmp_found_vms;
// -------------------------------------------------------------------------
// VM Collection
// -------------------------------------------------------------------------

View File

@ -248,6 +248,7 @@ int Host::update_info(Template &tmpl,
bool &with_vm_info,
set<int> &lost,
map<int,string> &found,
set<int> &found_twice,
const set<int> &non_shared_ds,
long long reserved_cpu,
long long reserved_mem)
@ -271,6 +272,7 @@ int Host::update_info(Template &tmpl,
set<int> prev_tmp_lost = tmp_lost_vms;
set<int> prev_tmp_zombie = tmp_zombie_vms;
set<int> prev_tmp_found = tmp_found_vms;
int num_zombies = 0;
int num_wilds = 0;
@ -337,6 +339,8 @@ int Host::update_info(Template &tmpl,
tmp_zombie_vms.clear();
tmp_found_vms.clear();
for (it = vm_att.begin(); it != vm_att.end(); it++)
{
vatt = dynamic_cast<VectorAttribute*>(*it);
@ -362,6 +366,13 @@ int Host::update_info(Template &tmpl,
if (tmp_lost_vms.erase(vmid) == 1) //Good, known
{
found.insert(make_pair(vmid, vatt->vector_value("POLL")));
tmp_found_vms.insert(vmid);
if (prev_tmp_found.count(vmid) == 1)
{
found_twice.insert(vmid);
}
}
else //Bad, known but should not be here
{

View File

@ -184,6 +184,7 @@ void MonitorThread::do_message()
set<int> lost;
map<int,string> found;
set<int> found_twice;
ostringstream oss;
@ -194,8 +195,8 @@ void MonitorThread::do_message()
return;
}
rc = host->update_info(tmpl, vm_poll, lost, found, non_shared_ds,
reserved_cpu, reserved_mem);
rc = host->update_info(tmpl, vm_poll, lost, found, found_twice,
non_shared_ds, reserved_cpu, reserved_mem);
hpool->update(host);
@ -252,7 +253,26 @@ void MonitorThread::do_message()
for (itm = found.begin(); itm != found.end(); itm++)
{
VirtualMachineManagerDriver::process_poll(itm->first, itm->second);
VirtualMachine * vm = vmpool->get(itm->first, true);
if (vm == 0)
{
continue;
}
// When a VM in poweroff is found again, it may be because of
// outdated poll information. To make sure, we check if VM was
// reported twice
if (vm->get_state() == VirtualMachine::POWEROFF &&
found_twice.count(itm->first) == 0)
{
vm->unlock();
continue;
}
VirtualMachineManagerDriver::process_poll(vm, itm->second);
vm->unlock();
}
}
};