From 59085947bf3d41b5ae172c628b79b41ed1d5ee19 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Oct 2016 12:00:52 +0200 Subject: [PATCH] F #4849: Add sched_message when a VM cannot be dispatched --- src/scheduler/include/VirtualMachineXML.h | 12 ---------- src/scheduler/src/sched/Scheduler.cc | 27 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/scheduler/include/VirtualMachineXML.h b/src/scheduler/include/VirtualMachineXML.h index 35e6badb54..c8978b0ebb 100644 --- a/src/scheduler/include/VirtualMachineXML.h +++ b/src/scheduler/include/VirtualMachineXML.h @@ -227,18 +227,6 @@ public: bool test_image_datastore_capacity( ImageDatastorePoolXML * img_dspool, string & error_msg) const; - /** - * Tests if the Image DS have enough free space to host the VM - * @param img_datastores Image Datastores - * @return true if the Image Datastores can host the VM - */ - bool test_image_datastore_capacity( - ImageDatastorePoolXML * img_dspool) const - { - string tmp_st; - return test_image_datastore_capacity(img_dspool, tmp_st); - } - /** * Adds the VM disk requirements to each Image Datastore counter * @param img_datastores Image Datastores diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index b6c5266d97..e60c0bc5e1 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -795,9 +795,9 @@ void Scheduler::match_schedule() } else { - log_match(vm->get_oid(), "Cannot schedule VM. "+m_error); + log_match(vm->get_oid(), "Cannot schedule VM. "+ m_error); - vm->log("Cannot schedule VM. "+m_error); + vm->log("Cannot schedule VM. "+ m_error); vmpool->update(vm); continue; @@ -1061,6 +1061,7 @@ void Scheduler::dispatch() VirtualMachineXML * vm; ostringstream dss; + string error; int cpu, mem; long long dsk; @@ -1069,6 +1070,7 @@ void Scheduler::dispatch() int hid, dsid, cid; unsigned int dispatched_vms = 0; + bool dispatched; map host_vms; pair::iterator, bool> rc; @@ -1091,6 +1093,8 @@ void Scheduler::dispatch() ( dispatch_limit <= 0 || dispatched_vms < dispatch_limit ); vm_it++) { + dispatched = false; + vm = static_cast(vm_it->second); const vector resources = vm->get_match_hosts(); @@ -1100,7 +1104,7 @@ void Scheduler::dispatch() //---------------------------------------------------------------------- if (!resources.empty() && !vm->is_resched() && !vm->is_resume()) { - if (vm->test_image_datastore_capacity(img_dspool) == false) + if (vm->test_image_datastore_capacity(img_dspool, error) == false) { if (vm->is_public_cloud())//No capacity needed for public cloud { @@ -1108,6 +1112,10 @@ void Scheduler::dispatch() } else { + vm->log("Cannot dispatch VM. " + error); + + vmpool->update(vm); + continue; } } @@ -1275,14 +1283,25 @@ void Scheduler::dispatch() dispatched_vms++; + dispatched = true; + break; } + + if (!dispatched) + { + vm->log("Cannot dispatch VM to any Host. Possible reasons: Not " + "enough capacity in Host or System DS, or dispatch limit " + "reached"); + vmpool->update(vm); + } } if (vm_it != pending_vms.end()) { dss << endl << "MAX_DISPATCH limit of " << dispatch_limit << " reached, " - << std::distance(vm_it, pending_vms.end()) << " VMs were not dispatched"; + << std::distance(vm_it, pending_vms.end()) + << " VMs were not dispatched"; } NebulaLog::log("SCHED", Log::DEBUG, dss);