mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Updating whole user_template may cause lost of data due to race conditions. It's better to send update only for modified attribute, in this case only SCHED_MESSAGE
This commit is contained in:
parent
f18fec70c4
commit
69f7b4d1f7
@ -457,6 +457,13 @@ protected:
|
||||
|
||||
void init_storage_usage();
|
||||
|
||||
/**
|
||||
* Update the VM object in oned
|
||||
* @param vm_template Object template as xml or ...
|
||||
* @param append Append mode
|
||||
*/
|
||||
bool update(const std::string &vm_template, bool append);
|
||||
|
||||
/* ---------------------- SCHEDULER INFORMATION ------------------------- */
|
||||
ResourceMatch match_hosts;
|
||||
|
||||
|
@ -238,15 +238,14 @@ int VirtualMachinePoolXML::load_info(xmlrpc_c::value &result)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePoolXML::dispatch(int vid, int hid, int dsid, bool resched,const string& extra_template) const
|
||||
int VirtualMachinePoolXML::dispatch(int vid, int hid, int dsid, bool resched,
|
||||
const string& extra_template) const
|
||||
{
|
||||
xmlrpc_c::value deploy_result;
|
||||
|
||||
VirtualMachineXML* vm = get(vid);
|
||||
|
||||
if (vm != 0 && vm->clear_log())
|
||||
if (auto vm = get(vid))
|
||||
{
|
||||
update(vm);
|
||||
vm->clear_log();
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -607,7 +607,14 @@ void VirtualMachineXML::log(const string &st)
|
||||
|
||||
oss << one_util::log_time() << ": " << st;
|
||||
|
||||
user_template->replace("SCHED_MESSAGE", oss.str());
|
||||
string sched_message = oss.str();
|
||||
|
||||
user_template->replace("SCHED_MESSAGE", sched_message);
|
||||
|
||||
oss.str("");
|
||||
oss << "SCHED_MESSAGE = \"" << sched_message << "\"";
|
||||
|
||||
update(oss.str(), true); // Send the update to oned
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -631,6 +638,8 @@ bool VirtualMachineXML::clear_log()
|
||||
|
||||
user_template->erase("SCHED_MESSAGE");
|
||||
|
||||
update("SCHED_MESSAGE = \"\"", true); // Send update to oned
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -672,3 +681,26 @@ int VirtualMachineXML::parse_action_name(string& action_st)
|
||||
return 0;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool VirtualMachineXML::update(const string &vm_template, bool append)
|
||||
{
|
||||
xmlrpc_c::value result;
|
||||
|
||||
try
|
||||
{
|
||||
Client::client()->call("one.vm.update", "isi", &result, oid,
|
||||
vm_template.c_str(),
|
||||
append ? 1 : 0);
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<xmlrpc_c::value> values =
|
||||
xmlrpc_c::value_array(result).vectorValueValue();
|
||||
|
||||
return xmlrpc_c::value_boolean(values[0]);
|
||||
}
|
||||
|
@ -895,7 +895,6 @@ void Scheduler::match_schedule()
|
||||
log_match(vm->get_oid(), "Cannot schedule VM. "+ m_error);
|
||||
|
||||
vm->log("Cannot schedule VM. "+ m_error);
|
||||
vmpool->update(vm);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -973,8 +972,6 @@ void Scheduler::match_schedule()
|
||||
}
|
||||
}
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
log_match(vm->get_oid(),
|
||||
"Cannot schedule VM, there is no suitable host.");
|
||||
|
||||
@ -1090,8 +1087,6 @@ void Scheduler::match_schedule()
|
||||
|
||||
vm->clear_match_hosts();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
log_match(vm->get_oid(), "Cannot schedule VM, there is no suitable "
|
||||
"system ds.");
|
||||
|
||||
@ -1194,8 +1189,6 @@ void Scheduler::match_schedule()
|
||||
vm->clear_match_hosts();
|
||||
vm->clear_match_datastores();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
log_match(vm->get_oid(), "Cannot schedule VM, there is no "
|
||||
"suitable network.");
|
||||
|
||||
@ -1339,8 +1332,6 @@ void Scheduler::dispatch()
|
||||
{
|
||||
vm->log("Cannot dispatch VM. " + error);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1664,7 +1655,6 @@ void Scheduler::dispatch()
|
||||
vm->log("Cannot dispatch VM to any Host. Possible reasons: Not "
|
||||
"enough capacity in Host or System DS, dispatch limit "
|
||||
"reached, or limit of free leases reached.");
|
||||
vmpool->update(vm);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user