mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
bug #4022: Do not set snapshots on persistent images if its TM ln mode
is SYSTEM. Update quota update and snapshot survival after delete --recreate according to: +--------+-------------------------------------+ |LN/CLONE| PERSISTENT | NO PERSISTENT | | |---------+---------+-----------------+ | TARGET | created | quota | created | quota | +--------+---------+---------+-----------------+ | SYSTEM | system | VM + DS | system | VM | | SELF | image | DS | image | DS | | NONE | image | DS | image | DS | +----------------------------------------------+ Snapshots created at system ds (LN_TARGET/TM_TARGET) will be deleted after a recreate. (cherry picked from commit c5ad05fc60680cda2763973f5079598c2bf166e7)
This commit is contained in:
parent
1b9919435e
commit
6bcc97bd08
@ -197,7 +197,7 @@ public:
|
||||
* *ARE FREED* by this function
|
||||
* @param ds_quotas a map with image_id and a tmpl with usage attributes
|
||||
*/
|
||||
static void bulk_ds_del(map<int, Template *>& ds_quotas);
|
||||
static void ds_del(map<int, Template *>& ds_quotas);
|
||||
|
||||
/**
|
||||
* Delete usage from the given quota counters.
|
||||
|
@ -1299,20 +1299,6 @@ public:
|
||||
*/
|
||||
static string disk_tm_target(const VectorAttribute * disk);
|
||||
|
||||
/**
|
||||
* Returns the disk SHARED attribute from the TM
|
||||
* @param disk
|
||||
* @return true or false.
|
||||
*/
|
||||
static bool disk_tm_shared(const VectorAttribute * disk)
|
||||
{
|
||||
bool shared;
|
||||
|
||||
disk->vector_value("SHARED", shared);
|
||||
|
||||
return shared;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of the security group IDs in use in this VM
|
||||
* @param sgs a set of security group IDs
|
||||
|
@ -140,13 +140,6 @@ void Datastore::disk_attribute(
|
||||
disk->replace("LN_TARGET", st);
|
||||
}
|
||||
|
||||
get_template_attribute("SHARED", st);
|
||||
|
||||
if(!st.empty())
|
||||
{
|
||||
disk->replace("SHARED", st);
|
||||
}
|
||||
|
||||
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
|
||||
{
|
||||
get_template_attribute((*it).c_str(), inherit_val);
|
||||
|
@ -946,7 +946,7 @@ int DispatchManager::resubmit(
|
||||
|
||||
if ( !ds_quotas.empty() )
|
||||
{
|
||||
Quotas::bulk_ds_del(ds_quotas);
|
||||
Quotas::ds_del(ds_quotas);
|
||||
}
|
||||
|
||||
if ( vm_quotas != 0 )
|
||||
|
@ -856,7 +856,7 @@ void LifeCycleManager::clean_action(int vid)
|
||||
|
||||
if ( !ds_quotas.empty() )
|
||||
{
|
||||
Quotas::bulk_ds_del(ds_quotas);
|
||||
Quotas::ds_del(ds_quotas);
|
||||
}
|
||||
|
||||
if ( vm_quotas != 0 )
|
||||
|
@ -1808,6 +1808,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
|
||||
bool is_persistent = VirtualMachine::is_persistent(disk);
|
||||
string target = VirtualMachine::disk_tm_target(disk);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -1837,7 +1838,8 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
delete vm_quotas;
|
||||
}
|
||||
|
||||
if(img_id != -1 && is_persistent && has_snaps)
|
||||
// Update image if it is persistent and ln mode does not clone it
|
||||
if ( img_id != -1 && is_persistent && has_snaps && target != "SYSTEM" )
|
||||
{
|
||||
imagem->set_image_snapshots(img_id, snaps);
|
||||
}
|
||||
@ -1943,6 +1945,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
|
||||
bool is_persistent = VirtualMachine::is_persistent(disk);
|
||||
string target = VirtualMachine::disk_tm_target(disk);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -1972,7 +1975,8 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
delete vm_quotas;
|
||||
}
|
||||
|
||||
if(img_id != -1 && is_persistent && has_snaps)
|
||||
// Update image if it is persistent and ln mode does not clone it
|
||||
if ( img_id != -1 && is_persistent && has_snaps && target != "SYSTEM" )
|
||||
{
|
||||
imagem->set_image_snapshots(img_id, snaps);
|
||||
}
|
||||
|
@ -2362,7 +2362,6 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
Template ds_deltas;
|
||||
Template vm_deltas;
|
||||
bool do_vm_quota;
|
||||
|
||||
int rc;
|
||||
int snap_id;
|
||||
@ -2393,8 +2392,9 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
string disk_size = disk->vector_value("SIZE");
|
||||
string ds_id = disk->vector_value("DATASTORE_ID");
|
||||
bool persistent = VirtualMachine::is_persistent(disk);
|
||||
bool is_volatile = VirtualMachine::is_volatile(disk);
|
||||
bool is_system = VirtualMachine::disk_tm_target(disk) == "SYSTEM";
|
||||
bool do_ds_quota = VirtualMachine::is_persistent(disk) || !is_system;
|
||||
|
||||
int img_id = -1;
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
@ -2414,7 +2414,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
RequestAttributes vm_att_quota;
|
||||
|
||||
//--------------------------- Persistent Images ----------------------------
|
||||
if (persistent)
|
||||
if (do_ds_quota)
|
||||
{
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
@ -2451,9 +2451,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
}
|
||||
|
||||
//--------------------- Account for System DS storage ----------------------
|
||||
do_vm_quota = (VirtualMachine::disk_tm_target(disk) != "NONE");// self or system
|
||||
|
||||
if (do_vm_quota)
|
||||
if (is_system)
|
||||
{
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op) == false )
|
||||
{
|
||||
@ -2471,7 +2469,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
if (!quota_resize_authorization(id, &vm_deltas, vm_att_quota))
|
||||
{
|
||||
if (persistent)
|
||||
if (do_ds_quota)
|
||||
{
|
||||
quota_rollback(&ds_deltas, Quotas::DATASTORE, ds_att_quota);
|
||||
}
|
||||
@ -2487,12 +2485,12 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
if (persistent)
|
||||
if (do_ds_quota)
|
||||
{
|
||||
quota_rollback(&ds_deltas, Quotas::DATASTORE, ds_att_quota);
|
||||
}
|
||||
|
||||
if (do_vm_quota)
|
||||
if (is_system)
|
||||
{
|
||||
quota_rollback(&vm_deltas, Quotas::VM, vm_att_quota);
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void Quotas::quota_del(QuotaType type, int uid, int gid, Template * tmpl)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Quotas::bulk_ds_del(map<int, Template *>& ds_quotas)
|
||||
void Quotas::ds_del(map<int, Template *>& ds_quotas)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImagePool * ipool = nd.get_ipool();
|
||||
|
@ -2425,7 +2425,7 @@ long long VirtualMachine::get_system_disk_size(Template * tmpl)
|
||||
{
|
||||
size += disk_size;
|
||||
}
|
||||
else if ( disk_tm_target(disk) != "NONE") // self or system
|
||||
else if ( disk_tm_target(disk) == "SYSTEM")
|
||||
{
|
||||
size += disk_size;
|
||||
|
||||
@ -4587,16 +4587,16 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id,
|
||||
delete tmp;
|
||||
}
|
||||
|
||||
if ( is_persistent(disk) )
|
||||
{
|
||||
if (is_persistent(disk) || disk_tm_target(disk) != "SYSTEM")
|
||||
{
|
||||
*ds_quotas = new Template();
|
||||
|
||||
(*ds_quotas)->add("DATASTORE", disk->vector_value("DATASTORE_ID"));
|
||||
(*ds_quotas)->add("SIZE", ssize);
|
||||
(*ds_quotas)->add("IMAGES",0 );
|
||||
}
|
||||
}
|
||||
|
||||
if (disk_tm_target(disk) != "NONE") // self or system
|
||||
if (disk_tm_target(disk) == "SYSTEM")
|
||||
{
|
||||
*vm_quotas = new Template();
|
||||
|
||||
@ -4609,6 +4609,16 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id,
|
||||
}
|
||||
}
|
||||
|
||||
// +--------+-------------------------------------+
|
||||
// |LN/CLONE| PERSISTENT | NO PERSISTENT |
|
||||
// | |---------+---------+-----------------+
|
||||
// | TARGET | created | quota | created | quota |
|
||||
// +--------+---------+---------+-----------------+
|
||||
// | SYSTEM | system | VM + DS | system | VM |
|
||||
// | SELF | image | DS | image | DS |
|
||||
// | NONE | image | DS | image | DS |
|
||||
// +----------------------------------------------+
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -4647,34 +4657,30 @@ void VirtualMachine::delete_non_persistent_disk_snapshots(Template **vm_quotas,
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( disk_tm_target(disk) != "SYSTEM" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_persistent(disk))
|
||||
{
|
||||
if (!disk_tm_shared(disk))
|
||||
{
|
||||
int image_id;
|
||||
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", it->second->get_total_size());
|
||||
d_ds->add("IMAGES", 0);
|
||||
|
||||
ds_quotas.insert(pair<int, Template *>(image_id, d_ds));
|
||||
}
|
||||
else
|
||||
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", it->second->get_total_size());
|
||||
d_ds->add("IMAGES", 0);
|
||||
|
||||
ds_quotas.insert(pair<int, Template *>(image_id, d_ds));
|
||||
}
|
||||
else if (disk_tm_target(disk) != "NONE") // self or system
|
||||
{
|
||||
system_disk += it->second->get_total_size();
|
||||
}
|
||||
|
||||
system_disk += it->second->get_total_size();
|
||||
|
||||
it->second->clear();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user