1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

B #6506: Fix quota after disk-attach for CEPH (#2949)

(cherry picked from commit 57d74662b1)
This commit is contained in:
Pavel Czerný 2024-02-22 13:15:22 +01:00 committed by Ruben S. Montero
parent ac2d356dab
commit 5d7ef79054
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 33 additions and 2 deletions

View File

@ -1875,7 +1875,7 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
return AUTHORIZATION;
}
if (volatile_disk == false)
if (!volatile_disk)
{
if ( quota_authorization(&tmpl, Quotas::IMAGE, att_quota, att.resp_msg) == false )
{
@ -1884,15 +1884,38 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
}
}
// Datastore quotas
vector<unique_ptr<Template>> ds_quotas;
VirtualMachineDisks::image_ds_quotas(&deltas, ds_quotas);
if ( !ds_quotas.empty() &&
!quota_authorization(ds_quotas[0].get(), Quotas::DATASTORE, att_quota, att.resp_msg))
{
quota_rollback(&deltas, Quotas::VM, att_quota);
if (!volatile_disk)
{
quota_rollback(&tmpl, Quotas::IMAGE, att_quota);
}
return AUTHORIZATION;
}
if ( dm->attach(id, &tmpl, att, att.resp_msg) != 0 )
{
quota_rollback(&deltas, Quotas::VM, att_quota);
if (volatile_disk == false)
if (!volatile_disk)
{
quota_rollback(&tmpl, Quotas::IMAGE, att_quota);
}
if (!ds_quotas.empty())
{
quota_rollback(ds_quotas[0].get(), Quotas::DATASTORE, att_quota);
}
return ACTION;
}

View File

@ -1049,6 +1049,14 @@ void VirtualMachinePool::delete_attach_disk(std::unique_ptr<VirtualMachine> vm)
if (!disk->is_persistent())
{
Quotas::quota_del(Quotas::VM, uid, gid, &tmpl);
vector<unique_ptr<Template>> ds_quotas;
VirtualMachineDisks::image_ds_quotas(&tmpl, ds_quotas);
if (!ds_quotas.empty())
{
Quotas::quota_del(Quotas::DATASTORE, uid, gid, ds_quotas[0].get());
}
}
const Snapshots * snaps = disk->get_snapshots();