Feature #1026

Deleted VM Cleanup

Added by Anonymous over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:12/12/2011
Priority:LowDue date:
Assignee:Ruben S. Montero% Done:

0%

Category:Core & System
Target version:Release 3.4 - Beta
Resolution:fixed Pull request:

Description

Currently the "onevm delete [ID]" only deletes the deployed instance of a virtual machine, but leaves it's folder intact. Therefore, upon deleting virtual machines, it becomes necessary to manually delete the folders of those virtual machines.

It should be possible to specify that onevm should delete the folder associated with a VM once the VM has been deleted. Possible implementation could be:
onevm delete [ID] --force
Or:
onevm delete [ID] --clean-up

History

#1 Updated by Carlos Martín over 9 years ago

This can implemented using hooks. Copied from the mailing list [1]:

VM_HOOK = [
   name      = "vmdir_cleanup",
   on        = "DONE",
   command   = "/bin/rm",
   arguments = "-r /var/lib/one/$VMID" ]

VM_HOOK = [
   name      = "log_cleanup",
   on        = "DONE",
   command   = "/bin/rm",
   arguments = "/var/log/one/$VMID.log" ]

I'll leave this open, maybe we should provide a default in oned.conf, or add this as an example to the documentation...

[1] http://lists.opennebula.org/pipermail/users-opennebula.org/2011-December/007333.html

#2 Updated by Anonymous over 9 years ago

Thank you very much Carlos! The solution you've given will be sufficient for what is needed in my OpenNebula deployment.

There is limited documentation describing what happens when a VM is deleted, or transitions to the DONE state. In my opinion it would be helpful if the following statement:

"The VM is done. VMs in this state won't be shown with “onevm list” but are kept in the database for accounting purposes"

Found here: http://opennebula.org/documentation:rel3.0:vm_guide_2

Was expanded to mention that files related to the VM are kept, and that hooks should be used to clean those files up if not needed by the cloud infrastructure owners.

The following addition to my oned.conf file is where I'm going with the solution you pointed out.

#*******************************************************************************
  1. Clean-Up Hooks #*******************************************************************************
  2. The following VM hooks can be activated in order to manage the clean-up of
  3. log, and deployment files after a VM has transitioned to the DONE state. #******************************************************************************* #
    #-------------------------------------------------------------------------------
  4. VM Clean-Up
    #------------------------------------------------------------------------------- #
  5. The vmdir_cleanup hook will remove the folder, and all its contents,
  6. associated with VMs that have transitioned to the DONE state. The log_cleanup
  7. hook will remove the OpenNebula log associated with the VM. #
    #-------------------------------------------------------------------------------

  8. #VM_HOOK = [
  9. name = "vmdir_cleanup",
  10. on = "DONE",
  11. command = "/bin/rm",
  12. arguments = "-r /var/lib/one/$VMID" ] #
    #VM_HOOK = [
  13. name = "log_cleanup",
  14. on = "DONE",
  15. command = "/bin/rm",
  16. arguments = "/var/log/one/$VMID.log" ] #

#3 Updated by Anonymous over 9 years ago

This solution won't work either. When the OpenNebula server is re-started, old folders are re-created. Not ALL folders beginning at VMID 1. Instead an assortment of folders for previously "DONE" VMs between 1 and the current VMID.

#4 Updated by Ruben S. Montero over 9 years ago

  • Target version set to Release 3.4

#5 Updated by Ruben S. Montero over 9 years ago

  • Assignee set to Ruben S. Montero
  • Target version changed from Release 3.4 to Release 3.4 - Beta

#6 Updated by Ruben S. Montero over 9 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

VM directories should not be recreated now. Closing this issue, and we'll reopen this if needed

Also available in: Atom PDF