1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

B #1398: Do not reset resizes and quotas after a recover --recreate

(cherry picked from commit 28f84b4513)
This commit is contained in:
Ruben S. Montero 2018-04-17 20:42:33 +02:00
parent 9ff88cdbfd
commit 0ec5986730
5 changed files with 2 additions and 133 deletions

View File

@ -1374,18 +1374,6 @@ public:
return disks.set_up_resize(disk_id, size, error);
}
/**
* Restore original disk sizes for non-persistentand for persistent disks
* in no shared system ds.
* @param vm_quotas The SYSTEM_DISK_SIZE freed by the deleted snapshots
* @param ds_quotas The DS SIZE freed from image datastores.
*/
void delete_non_persistent_disk_resizes(Template **vm_quotas,
vector<Template *>& ds_quotas)
{
disks.delete_non_persistent_resizes(vm_quotas, ds_quotas);
}
// ------------------------------------------------------------------------
// NIC Hotplug related functions
// ------------------------------------------------------------------------

View File

@ -742,15 +742,6 @@ public:
void delete_non_persistent_snapshots(Template **vm_quotas,
vector<Template *> &ds_quotas);
/**
* Restores the disk original size for non-persistent and for persistent
* disks in no shared system ds.
* @param vm_quotas The SYSTEM_DISK_SIZE freed by the deleted snapshots
* @param ds_quotas The DS SIZE freed from image datastores.
*/
void delete_non_persistent_resizes(Template **vm_quotas,
vector<Template *> &ds_quotas);
protected:
VirtualMachineAttribute * attribute_factory(VectorAttribute * va,

View File

@ -1091,10 +1091,8 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
int rc = 0;
Template * vm_quotas_snp = 0;
Template * vm_quotas_rsz = 0;
vector<Template *> ds_quotas_snp;
vector<Template *> ds_quotas_rsz;
int vm_uid, vm_gid;
@ -1123,10 +1121,8 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
vm_uid = vm->get_uid();
vm_gid = vm->get_gid();
vm->delete_non_persistent_disk_snapshots(&vm_quotas_rsz,
ds_quotas_rsz);
vm->delete_non_persistent_disk_resizes(&vm_quotas_rsz,
ds_quotas_rsz);
vm->delete_non_persistent_disk_snapshots(&vm_quotas_snp,
ds_quotas_snp);
case VirtualMachine::HOLD:
if (vm->hasHistory())
@ -1162,11 +1158,6 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_snp);
}
if ( !ds_quotas_rsz.empty() )
{
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_rsz);
}
if ( vm_quotas_snp != 0 )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_snp);
@ -1174,13 +1165,6 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
delete vm_quotas_snp;
}
if ( vm_quotas_rsz != 0 )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_rsz);
delete vm_quotas_rsz;
}
return rc;
}

View File

@ -829,10 +829,8 @@ void LifeCycleManager::delete_action(const LCMAction& la)
void LifeCycleManager::delete_recreate_action(const LCMAction& la)
{
Template * vm_quotas_snp = 0;
Template * vm_quotas_rsz = 0;
vector<Template *> ds_quotas_snp;
vector<Template *> ds_quotas_rsz;
int vm_uid, vm_gid;
@ -876,9 +874,6 @@ void LifeCycleManager::delete_recreate_action(const LCMAction& la)
vm->delete_non_persistent_disk_snapshots(&vm_quotas_snp,
ds_quotas_snp);
vm->delete_non_persistent_disk_resizes(&vm_quotas_rsz,
ds_quotas_rsz);
vmpool->update(vm);
break;
}
@ -904,24 +899,12 @@ void LifeCycleManager::delete_recreate_action(const LCMAction& la)
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_snp);
}
if ( !ds_quotas_rsz.empty() )
{
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_rsz);
}
if ( vm_quotas_snp != 0 )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_snp);
delete vm_quotas_snp;
}
if ( vm_quotas_rsz != 0 )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_rsz);
delete vm_quotas_rsz;
}
}
/* -------------------------------------------------------------------------- */

View File

@ -1553,80 +1553,3 @@ int VirtualMachineDisks::get_saveas_info(int& disk_id, string& source,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineDisks::delete_non_persistent_resizes(Template **vm_quotas,
vector<Template *>& ds_quotas)
{
long long original_size, size, delta_size, system_disk = 0;
string tm_target;
int rc;
for ( disk_iterator disk = begin() ; disk != end() ; ++disk )
{
tm_target = (*disk)->get_tm_target();
rc = (*disk)->vector_value("SIZE", size);
rc += (*disk)->vector_value("ORIGINAL_SIZE", original_size);
if ( rc != 0 || original_size >= size || tm_target == "NONE" )
{
continue;
}
delta_size = original_size - size;
//Quotas uses del operation to substract counters, delta needs to be > 0
if ( delta_size < 0 )
{
delta_size = - delta_size;
}
bool vm_owner = tm_target == "SELF";
bool img_owner = (*disk)->is_persistent();
// Decrement DS quota on disks that do not modify the original image
if ( vm_owner || img_owner )
{
int image_id;
if ( (*disk)->vector_value("IMAGE_ID", image_id) != 0 )
{
continue;
}
Template * d_ds = new Template();
d_ds->add("DATASTORE", (*disk)->vector_value("DATASTORE_ID"));
d_ds->add("SIZE", delta_size);
d_ds->add("IMAGES", 0);
d_ds->add("IMAGE_ID", image_id);
d_ds->add("VM_QUOTA", vm_owner);
d_ds->add("IMG_QUOTA", img_owner);
ds_quotas.push_back(d_ds);
}
if ( tm_target == "SYSTEM" )
{
system_disk += delta_size;
}
(*disk)->replace("SIZE", original_size);
}
if ( system_disk > 0 )
{
*vm_quotas = new Template();
VectorAttribute * delta_disk = new VectorAttribute("DISK");
delta_disk->replace("TYPE", "FS");
delta_disk->replace("SIZE", system_disk);
(*vm_quotas)->add("VMS", 0);
(*vm_quotas)->set(delta_disk);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */