Skip to content

Commit

Permalink
B OpenNebula#2053: Do not return failure on recursive delete (OpenNeb…
Browse files Browse the repository at this point in the history
…ula#1250)

(cherry picked from commit 18aee65)
  • Loading branch information
Pavel Czerný authored and atodorov-storpool committed Jun 1, 2021
1 parent 6f9b93c commit 12161b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rm/RequestManagerDelete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,

VirtualMachineDisks disks(true);

int tid = object->get_oid();

if (recursive)
{
static_cast<VMTemplate *>(object.get())->clone_disks(vdisks);
Expand Down Expand Up @@ -262,18 +264,20 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
{
if ( img_delete.request_execute(iid, att) != SUCCESS )
{
NebulaLog::log("ReM", Log::ERROR, att.resp_msg);
NebulaLog::warn("ReM", att.resp_msg);

error_ids.insert(iid);
}
}

if ( !error_ids.empty() )
{
att.resp_msg = "Cannot delete " + object_name(PoolObjectSQL::IMAGE) +
att.resp_msg = "Template " + to_string(tid) +
" deleted, unable to recursively delete " +
object_name(PoolObjectSQL::IMAGE) +
": " + one_util::join(error_ids.begin(), error_ids.end(), ',');

return -1;
NebulaLog::warn("ReM", att.resp_msg);
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/vm/VirtualMachineDisk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ int VirtualMachineDisk::get_image_id(int &id, int uid) const
{
id = image->get_oid();
}
else
{
return -1;
}

return 0;
}
Expand Down

0 comments on commit 12161b6

Please sign in to comment.