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

F #2347: Re-evaluate host requirements in dispatch loop to fulfil anti-affinity rules

This commit is contained in:
Ruben S. Montero 2017-01-25 23:37:50 +01:00
parent 5bd214ab00
commit 90ed2f5c28
2 changed files with 31 additions and 8 deletions

View File

@ -351,12 +351,12 @@ static void schecule_affined_set(std::set<int> vms,
}
else
{
std::ostringstream oss;
std::ostringstream oss_reqs;
std::string reqs;
VMGroupRole::host_requirements(hosts, "=", "|", oss);
VMGroupRole::host_requirements(hosts, "=", "|", oss_reqs);
reqs = oss.str();
reqs = oss_reqs.str();
for ( it = vms.begin() ; it != vms.end() ; ++it )
{

View File

@ -598,7 +598,8 @@ static bool match_host(AclXML * acls, UserPoolXML * upool, VirtualMachineXML* vm
if (matched == false)
{
error = "It does not fulfill SCHED_REQUIREMENTS.";
error = "It does not fulfill SCHED_REQUIREMENTS: " +
vm->get_requirements();
return false;
}
}
@ -873,7 +874,8 @@ void Scheduler::match_schedule()
vmpool->update(vm);
log_match(vm->get_oid(), "Cannot schedule VM, there is no suitable host.");
log_match(vm->get_oid(),
"Cannot schedule VM, there is no suitable host.");
continue;
}
@ -1072,7 +1074,8 @@ void Scheduler::dispatch()
int hid, dsid, cid;
unsigned int dispatched_vms = 0;
bool dispatched;
bool dispatched, matched;
char * estr;
map<int, ObjectXML*>::const_iterator vm_it;
@ -1137,6 +1140,26 @@ void Scheduler::dispatch()
cid = host->get_cid();
//------------------------------------------------------------------
// Check host still match requirements for ANTI_AFFINITY rules
//------------------------------------------------------------------
if ( host->eval_bool(vm->get_requirements(), matched, &estr) != 0 )
{
free(estr);
continue;
}
if (matched == false)
{
std::ostringstream mss;
mss << "Host " << hid << " no longer meets requirements for VM "
<< vm->get_oid() << "\n";
NebulaLog::log("SCHED", Log::DEBUG, mss);
continue;
}
//------------------------------------------------------------------
// Test host capacity
//------------------------------------------------------------------
@ -1415,11 +1438,11 @@ void Scheduler::do_vm_groups()
oss << *grp << "\n";
grp->set_affinity_requirements(vmpool, vm_roles_pool, oss);
grp->set_antiaffinity_requirements(vmpool, oss);
grp->set_host_requirements(vmpool, oss);
grp->set_affinity_requirements(vmpool, vm_roles_pool, oss);
}
NebulaLog::log("VMGRP", Log::DDDEBUG, oss);