Feature #3782
Ceph snapshots
Status: | Closed | Start date: | 04/29/2015 | |
---|---|---|---|---|
Priority: | Sponsored | Due date: | ||
Assignee: | Ruben S. Montero | % Done: | 0% | |
Category: | Core & System | |||
Target version: | Release 4.14 | |||
Resolution: | fixed | Pull request: |
Description
We are using ceph as our storage platform for all that we do.
We would like to be able to snapshot ceph thourgh opennebula.
First usecase can be described as follows:
We use the opennebula api to deploy a VM. We define that the VM should have additional rbd's attached as storage devices for docker running inside the VM.
After a while we use salt-stack to upgrade the docker image running on the additional rbd storage devices. Before we upgrade the docker image we create a snapshot of the rbd device through the opennebula api. After the upgrade we find some problem with the upgraded docker image and run salt-stack to revert the rbd to the previous snapshot of the rbd through the opennebula api.
After some time of operation of the VM I login to the sunstone interface and browse to the VM and browse the storage attached to the where I can se the number of snapshots and the amount of space that it occupies.
Second usecase:
We operate a regular VM that we need to do some major upgrades to, we start by doing a snapshot of the VM's storage, eighter through sunstone or opennebula api. Do the upgrade and tries to verify that the upgrade went as expected.
The upgrade failed and we revert to the snapshot before the upgrade, eighter through sunstone or opennebula api.
Associated revisions
feature #3782: Initial class for Snapshot list
feature #3782: Create and Revert operations for Disk Snapshots. Core and
OCA levels
feature #3782: Add DISK_SNAPSHOT_POWEROFF state
feature #3782: add snapshots to onevm show
feature #3782: Generate snapshot files for TransferManager
feature #3782: Remove SOURCE and PARENT from snapshots. Drivers MUST
generate internal snapshot references from snapshot_id, parent_id
feature #3782: Snapshot event triggers
feature #3782: Re-design of revert operation. New action for drivers, and new state.
feature #3782: Deal with snapshot id=0
feature #3782: Add children list. Rename PARENT_ID to PARENT
feature #3782: New state to delete snapshots. Delete action OCA (Ruby),
core and CLI
Feature #3782: Add ceph disk snapshot actions
Feature #3782: remove debug info
Feature #3782: add support for snapshots of persistent images in ceph
feature #3782: Update copy constructor for Template. It should purge
before copying. Adds a generic clear() method, and use it in class
implementation
feature #3782: Copy constructor for Snapshots. Used to transfer the
snapshot lisk from VM disk to Image objects
feature #3782: Add snapshots to Image object. Transfer them back from VM
disk
feature #3782: Assignment copy constructor for Snapshots. Clear disk_id
feature #3782: Copy assignment operator for Templates
feature #3782: Copy snapshots from Image to VM disks, and back. Still
needs to do the same on attach dettach operations
feature #3782: Transfer snapshot list from/to attach disks
feature #3782: Image with snapshots cannot be made non-persistent
feature #3782: Image with snapshots can be only of type OS or DATABLOCK
feature #3782: Cannot clone images with snapshots
feature #3782: Display snapshots in oneimage show
feature #3782: Delete operations are now two-phase. More checks on
disk-snapshots actions. Improve const-ness of Snapshot class
feature #3782: Add missing unlocks to failure exits
feature #3782: Snapshot operations for Image class. Add target_snapshot to
Image class to identify operation on progress
feature #3782: Delete operations for image snapshots. Core image manager
and driver functions
feature #3782: Image XML-RPC methods for snapshot delete
feature #3782: Ruby OCA method for snapshot-delete, cli command.
Datastore driver action for snapshot delete
feature #3782: Revert action for images
feature #3782: Image are in LOCKED state while performing snapshot
operations
feature #3782: Flatten action for Images
Feature #3782: Action for Ceph snapshot flatten
Feature #3782: Update install.sh and remotes with ds snap actions
Feature #3782: Add dummy snapshot_* placeholders for all the TM drivers but Ceph
feature #3782: Do not snapshot volatile disks
feature #3782: Remove snapshot list if empty
feautre #3782: Remove SAVE_AS from core
feature #3782: Changes in OCA (Ruby) and CLI. Updated direct references
to OCA methods
feature #3782: Removed _hot from saveas functions
feature #3782: renamed method to disksaveas, cli and Ruby OCA. Added
snap id to save as disks
feature #3782: add qcow2 tm/snap_{create,revert}
feature #3782: add qcow2 tm/snap_delete
feature #3782: allow disk-saveas operations on the currently running disk
feature #3782: Add snapshot id to the onevm disk-saveas command
feature #3782: Update ceph cpds and mvds scripts to handle snaps
feature #3782: Update all cpds to include the SNAP_ID parameter
Feature #3782: Remove debugging data
Feature #3782: Simplify all TM/mvds action as now they don't handle
deferred saveas
feature #3782: Fix comment
feature #3782: Fix return codes
feature #3782: Size for snapshots (Virtual size). Renamed is* functions to is_* in VirtualMachine.
feature #3782: Update quotas on non-persistent snapshots
feature #3782: Update quotas for snapshots on non-persistent disks on
disk detach and vm done
feature #3782: Quotas for single snapshot deletion
feature #3782: Snapshots do not increment IMAGE counter in datastore for
persistent images
feature #3782: Return disk and snapshot information for Ceph disks
feature #3782: Quotas for one.image snapshots actions
feature #3782: snap_create for persistent qcow2
feature #3782: cpds support for qcow2 snapshots
feature #3782: Make IMAGE attribute mandatory
feature #3782: Add prefix to attach disk CLI options
feature #3782: tm/snap_revert for persistent qcow2
feature #3782: remove duplicate code in qcow2 snap_create
feature #3782: ds/snap_revert for qcow2
feature #3782: ds/snap_delete for qcow2
feature #3782: ds/snap_flatten for qcow2
feature #3782: tm/snap_delete for presistent qcow2
feature #3782: Snapshots in SUSPENDED state + dummy changed to exit 0
feature #3782: make tm qcow2 snap commands use ssh
feature #3782: Add snap actions to tm/shared
Feature #3782: Add disk snapshots to sunstone
Feature #3782: Update Sunstone minimized files
Feature #3782: Implement disk-saveas in sunstone
Feature #3782: Update Sunstone minimized files
Feature #3782: Add image snapshots to sunstone
Feature #3782: Add image snapshots to java api
feature #3782: Delete snapshots in RUNNING. Added new states for disk
snapshots in running
feature #3782: Removed unused method
feature #3782: add snapshot functionality to tm/ssh
feature #3782: Snapshots in RUNNING state
feature #3782: Restore line removed accidentally
feature #3782: Revert in RUNNING state
Feature #3782: Minor fixes to oned code
feature #3782: Updated not_supported action to make use of logging functions
Feature #3782: Use int instead of unsigned int for snapshot IDs
Feature #3782: Remove unused param from ImageManager::set_image_snapshots
Feature #3782: Add disk snapshot actions to java api
Feature #3782: Add confirmation dialogs to snapshot actions
Feature #3782: Add image snapshot attributes in onedb upgrade
Feature #3782: Allow to revert to active disk snapshot in sunstone
Feature #3782: Add disk-snapshot commands to states-complete.dot
Feature #3782: Add disk-snapshot commands to sunstone state-actions.js
feature #3782: Snapshots (create & revert operations) in running can be
performed either in a suspend/snap/restore cycle or in a detach/snap/attach one.
Allow to revert to the current snapshot
Feature #3782: Rename disk snapshot tag to name
Feature #3782: Add new history reasons to xsd and sunstone
Feature #3782: Update fsck for new DS and volatile quotas
Feature #3782: Disk-snapshot actions operate on persistent images
For persisten images, quota usage is taken from the image owner.
The image snapshots are now in sync during the VM lifecycle, not
just when the VM is shutdown. This was needed because the quota
size is now the image size + image quotas, and it caused problems
if the owner was changed with snapshots pending to be saved back
to the image.
Feature #3782: Update deprecated alias for saveas
Feature #3782: Update fsck. Image snapshots are in sync with their VM disks
Feature #3782: Add ATTACH=YES xml to DISK, not TARGET
feature #3782: Lazy auth for Snapshots methods
feature #3782: Add --live_snapshots option to vmm
This option make vmm skip detach/suspend phase for live
snapshots. By default it does live snapshots when vmm
is "kvm" and tm is "qcow2"
feature #3782: support multiple xpath values
xpath.rb will return multiple values if the xpath
starts with "%m%"
feature #3782: live snapshots for qcow2
feature #3782: Fix merge with resize clone
Feature #3782: Remove disk-snapshot action for volatile disks
Feature #3782: Alternate strategy for qcow2/snap_create
Revert "Feature #3782: Alternate strategy for qcow2/snap_create"
This reverts commit 4b4dc90eb62b2cfff15a98576cb7c40cffaa9c90.
Feature #3782: Clean code, refactor and fix concept errors
Feature #3782: qcow2/ln is no longer a symlink to shared/ln
Feature #3782: fs ds drivers now handle qcow2 and
raw in the snap_* actions
Feature #3782: Refactor and separate snap_create into two:
snap_create and snap_create_live
Feature #3782: make 'suspend' the default disk snapshot technique
Feature #3782: disable default live disk snapshot
feature #3782: bug in qcow2 cpds
feature #3782: bugs in qcow2 snap_create_live
feature #3782: create snap dir link for persistent images
feature #3782: fix monitoring of persistent images
Feature #3782: Display correct states for disk-snapshot-* operations
History
#1 Updated by Ruben S. Montero about 6 years ago
- Tracker changed from Request to Feature
- Category set to Core & System
- Priority changed from Normal to Sponsored
- Target version set to Release 4.14
#2 Updated by Ruben S. Montero about 6 years ago
- Assignee set to Ruben S. Montero
#3 Updated by Gerben Meijer about 6 years ago
I've reviewed the commits and as far as I can see, the current iteration of this only allows snapshots to be made with the VM powered off?
I think it would be beneficial to include the ability to snapshot without powering off the VM. I am well aware of the implications of snapshotting a disk live outside the OS when there is no way to know if the data is flushed to disk, however there are a few good reasons why this is still something that is good to have:
- A live disk snapshot in an unknown state is better than no snapshot at all, specifically for cases where a VM cannot be powered off due to customer requirements
- In most cases a live snapshot of a disk for a VM using a journalled filesystem without a guest agent running is recoverable without issues (provided that there is no write back caching going on in qemu, which may not apply to CEPH but does apply to other potential storage systems that support snapshots)
- The fsfreeze feature in the guest agent can be leveraged to trigger a freeze in the guest to ensure sync status, then take a snapshot outside of the VM, and finally thaw it after the snapshot action has been taken (see http://wiki.qemu.org/Features/QAPI/GuestAgent for details)
I'm not aware of guest agent support, but that can be implemented as a new feature at a later date - live snapshotting does not explicitly require it and documentation can reflect the risks, with a safe default of not allowing it if so desired.
#4 Updated by Ruben S. Montero about 6 years ago
Gerben Meijer wrote:
I've reviewed the commits and as far as I can see, the current iteration of this only allows snapshots to be made with the VM powered off?
I think it would be beneficial to include the ability to snapshot without powering off the VM. I am well aware of the implications of snapshotting a disk live outside the OS when there is no way to know if the data is flushed to disk, however there are a few good reasons why this is still something that is good to have:
- A live disk snapshot in an unknown state is better than no snapshot at all, specifically for cases where a VM cannot be powered off due to customer requirements
- In most cases a live snapshot of a disk for a VM using a journalled filesystem without a guest agent running is recoverable without issues (provided that there is no write back caching going on in qemu, which may not apply to CEPH but does apply to other potential storage systems that support snapshots)
- The fsfreeze feature in the guest agent can be leveraged to trigger a freeze in the guest to ensure sync status, then take a snapshot outside of the VM, and finally thaw it after the snapshot action has been taken (see http://wiki.qemu.org/Features/QAPI/GuestAgent for details)
I'm not aware of guest agent support, but that can be implemented as a new feature at a later date - live snapshotting does not explicitly require it and documentation can reflect the risks, with a safe default of not allowing it if so desired.
Hi Gerben Meijer
Yes you are right, this is the initial code to test things, you know ;). Once most of the machinery is in place, we'll add the RUNNING state as possible and test things. For example, we want to stress libvirt when reverting to a snaphost (the original block or file will be replaced by another one and that may not play nicely with qemu/libvirt)...
THANKS FOR YOUR FEEDBACK :)
#5 Updated by Ruben S. Montero about 6 years ago
Needed modificactions:
Compatibility
- Clone cannot be perform on images with snapshots
- Image with snapshots can be only of OS and DATA type (chtype enforce that)
- Image with snapshots can be only persistent (persistent api enforce that)
Upgrade
- 3 new states for disk-snapshot operations
- New field <TARGET_SNAPSHOT> that marks active snapshot operation (smilar to CLONING_ID)
- New driver operations
- TM: snap_create, snap_delete, snap_revert + update of mvds and rm
- DS: snap_delete, snap_revert, snap_flatten + update of delete
- Migrator to add IMAGE element
API
- disk and image operations. OCA JAVA missing
Sunstone
- Refactor of VM disk tab
- Add snapshot tab for Images
#6 Updated by Ruben S. Montero about 6 years ago
Updates:
- level JAVA API with the new one.vm.disksaveas, this replaces the old disk_snapshot api call, and onevm.saveas method
- Check that JSON classes used by Sunstone are properly updated
- Sunstone needs to re-work the snapshot/saveas interface
- Datamodel, removed DISK fields SAVE_AS_SOURCE, SAVE_AS and SAVE_AS_ACTIVE are not in use anymore, code should not check against those.
- Check EC2 API's
- Applications using disk_snapshot API call needs to upgrade to the new functionality
- New API call, with optional snap_id parameter
- Deferred snapshots are superseded by the new snapshoting functionality
- CPDS has a new argument, positional parsing of arguments by custom scripts needs to be updated
- Removed cancelsaveas, not needed anymore
- VMs with snapshot deferred will not perform the saveas operation, needs to be manually triggered, and placeholder images maybe left in locked state (need to remove them) *
#7 Updated by Ruben S. Montero about 6 years ago
Evaluate migrators for VMs with SAVE_AS=YES (deferred)
#8 Updated by Jaime Melis about 6 years ago
libvirt/qemu currently does not allow reopening the disk to account for a disk change, which is what's happening in the snapshot-create operation. For the moment we will allow snapshot-create to be triggered in POWEROFF and SUSPENDED states. This will change once libvirt exposes an interface to make this change.
#9 Updated by Stefan Kooman almost 6 years ago
@Jaime Meles libvirt/qemu currently does not allow reopening the disk to account for a disk change, which is what's happening in the snapshot-create operation. For the moment we will allow snapshot-create to be triggered in POWEROFF and SUSPENDED states. This will change once libvirt exposes an interface to make this change.
^^ when snapshots are created using "virsh snapshot-create-as" there is no need to notify libvirt/qemu of a disk change, as this is done automatically (intrinsic action of snapshot-create-as operation").
virsh help snapshot-create-as
NAME
snapshot-create-as - Create a snapshot from a set of args
SYNOPSIS
snapshot-create-as <domain> [--name <string>] [--description <string>] [--print-xml] [--no-metadata] [--halt] [--disk-only] [--reuse-external] [--quiesce] [--atomic] [--live] [--memspec <string>] [[--diskspec] <string>]..
According to this mail thread: https://www.redhat.com/archives/libvirt-users/2013-September/msg00146.html, this feature request: http://tracker.ceph.com/issues/2773 and the above output it should be possible to create a "--disk-only" snapshot on a live running VM. I have tested this on a qcow2 backed VM and this works. Unfortunately I do not (yet) have a CEPH cluster to test against but it's worth a try.
[--diskspec] <string> disk attributes: disk[,snapshot=type][,driver=type][,file=name].
^^ CEPH specific parameters shoud be filled in.
#10 Updated by Ruben S. Montero almost 6 years ago
- Status changed from Pending to Closed
- Resolution set to fixed
#11 Updated by Guillaume Michaud over 5 years ago
Hi,
Disk snapshot on a live running VM with Ceph backend does not seems to trigger the guest-fsfreeze-freeze/thaw commands on the guest. Is it supported in one-4.14.2?
Followed this procedure : http://www.sebastien-han.fr/blog/2015/02/09/openstack-perform-consistent-snapshots-with-qemu-guest-agent/
Works well if I trigger the command manually from the host (/tmp/freeze is filled with I'm frozen/I'm thaw). But nothing happen if I snapshot the disk manually from Sunstone.
#12 Updated by Ruben S. Montero over 5 years ago
Hi,
It's been called here
https://github.com/OpenNebula/one/blob/release-4.14.2/src/tm_mad/ceph/snap_create_live#L95
Could it be some problems with libvirtd/qemu version?
Guillaume Michaud wrote:
Hi,
Disk snapshot on a live running VM with Ceph backend does not seems to trigger the guest-fsfreeze-freeze/thaw commands on the guest. Is it supported in one-4.14.2?
Followed this procedure : http://www.sebastien-han.fr/blog/2015/02/09/openstack-perform-consistent-snapshots-with-qemu-guest-agent/
Works well if I trigger the command manually from the host (/tmp/freeze is filled with I'm frozen/I'm thaw). But nothing happen if I snapshot the disk manually from Sunstone.
#13 Updated by Guillaume Michaud over 5 years ago
Hi Ruben,
As I understand, the virsh command is called from the frontend but it is not installed my CentOS 7 frontend. I have to install the libvirt package to get it.
I installed my frontend using the official ONE repo and "yum install opennebula-server opennebula-sunstone" command.
Thanks.
Ruben S. Montero wrote:
Hi,
It's been called here
https://github.com/OpenNebula/one/blob/release-4.14.2/src/tm_mad/ceph/snap_create_live#L95
Could it be some problems with libvirtd/qemu version?
Guillaume Michaud wrote:
Hi,
Disk snapshot on a live running VM with Ceph backend does not seems to trigger the guest-fsfreeze-freeze/thaw commands on the guest. Is it supported in one-4.14.2?
Followed this procedure : http://www.sebastien-han.fr/blog/2015/02/09/openstack-perform-consistent-snapshots-with-qemu-guest-agent/
Works well if I trigger the command manually from the host (/tmp/freeze is filled with I'm frozen/I'm thaw). But nothing happen if I snapshot the disk manually from Sunstone.
#14 Updated by Guillaume Michaud over 5 years ago
Installing libvirt-client on the frontend does not make a difference. So I understand that the virsh command is called directly on the host.
Executing "virsh -c qemu:///system domfsfreeze one-546" on the host trigger the fshook correctly in the guest.
Just want to be sure, I'm talking about disk-snapshoting and not VM-snapshoting. On the Storage tab, I'm using the snapshot option for the vda disk (ID-0).
Thanks.