1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Bug #3832: Scheduler detects VMs to be resumed instead of first deployments

This commit is contained in:
Carlos Martín 2015-07-29 18:23:16 +02:00
parent 2d1b92fc24
commit c9ccd944d0
4 changed files with 53 additions and 11 deletions

View File

@ -91,6 +91,11 @@ public:
return (resched == 1);
}
bool is_resume() const
{
return resume;
}
const string& get_rank()
{
return rank;
@ -335,6 +340,7 @@ protected:
int dsid;
int resched;
bool resume;
int memory;
float cpu;

View File

@ -35,7 +35,8 @@ int VirtualMachinePoolXML::set_up()
{
oss << "Pending/rescheduling VM and capacity requirements:" << endl;
oss << right << setw(8) << "VM" << " "
oss << right << setw(8) << "ACTION" << " "
<< right << setw(8) << "VM" << " "
<< right << setw(4) << "CPU" << " "
<< right << setw(11) << "Memory" << " "
<< right << setw(11) << "System DS" << " "
@ -46,12 +47,23 @@ int VirtualMachinePoolXML::set_up()
{
int cpu, mem;
long long disk;
string action = "DEPLOY";
VirtualMachineXML * vm = static_cast<VirtualMachineXML *>(it->second);
vm->get_requirements(cpu, mem, disk);
if (vm->is_resched())
{
action = "RESCHED";
}
else if (vm->is_resume())
{
action = "RESUME";
}
oss << endl
<< right << setw(8) << action << " "
<< right << setw(8) << it->first << " "
<< right << setw(4) << cpu << " "
<< right << setw(11) << mem << " "

View File

@ -20,12 +20,15 @@
#include "DatastoreXML.h"
#include "DatastorePoolXML.h"
#include "NebulaUtil.h"
#include "History.h"
void VirtualMachineXML::init_attributes()
{
vector<string> result;
vector<xmlNodePtr> nodes;
int action;
string automatic_requirements;
oid = atoi(((*this)["/VM/ID"] )[0].c_str());
@ -172,6 +175,12 @@ void VirtualMachineXML::init_attributes()
resched = 0;
}
this->xpath(action, "/VM/HISTORY_RECORDS/HISTORY/ACTION", -1);
resume = (action == History::STOP_ACTION ||
action == History::UNDEPLOY_ACTION ||
action == History::UNDEPLOY_HARD_ACTION );
if (get_nodes("/VM/TEMPLATE", nodes) > 0)
{
vm_template = new VirtualMachineTemplate;

View File

@ -654,9 +654,11 @@ static bool match_system_ds(AclXML * acls, VirtualMachineXML* vm, long long vdis
// -------------------------------------------------------------------------
// Check datastore capacity for shared systems DS (non-shared will be
// checked in a per host basis during dispatch)
// checked in a per host basis during dispatch). Resume actions do not
// add to shared system DS usage, and are skipped also
// -------------------------------------------------------------------------
if (ds->is_shared() && ds->is_monitored() && !ds->test_capacity(vdisk, error))
if (ds->is_shared() && ds->is_monitored() && !vm->is_resume() &&
!ds->test_capacity(vdisk, error))
{
return false;
}
@ -757,9 +759,9 @@ void Scheduler::match_schedule()
n_error = 0;
//----------------------------------------------------------------------
// Test Image Datastore capacity, but not for migrations
// Test Image Datastore capacity, but not for migrations or resume
//----------------------------------------------------------------------
if (!vm->is_resched())
if (!vm->is_resched() && !vm->is_resume())
{
if (vm->test_image_datastore_capacity(img_dspool, m_error) == false)
{
@ -1054,10 +1056,10 @@ void Scheduler::dispatch()
const vector<Resource *> resources = vm->get_match_hosts();
//--------------------------------------------------------------
// Test Image Datastore capacity, but not for migrations
//--------------------------------------------------------------
if (!resources.empty() && !vm->is_resched())
//----------------------------------------------------------------------
// Test Image Datastore capacity, but not for migrations or resume
//----------------------------------------------------------------------
if (!resources.empty() && !vm->is_resched() && !vm->is_resume())
{
if (vm->test_image_datastore_capacity(img_dspool) == false)
{
@ -1157,7 +1159,16 @@ void Scheduler::dispatch()
{
if (ds->is_shared() && ds->is_monitored())
{
test_cap_result = ds->test_capacity(dsk);
// A resume action tests DS capacity only
// for non-shared system DS
if (vm->is_resume())
{
test_cap_result = true;
}
else
{
test_cap_result = ds->test_capacity(dsk);
}
}
else
{
@ -1199,7 +1210,11 @@ void Scheduler::dispatch()
{
if (ds->is_shared() && ds->is_monitored())
{
ds->add_capacity(dsk);
// Resumed VMs do not add to shared system DS capacity
if (!vm->is_resume())
{
ds->add_capacity(dsk);
}
}
else
{