Skip to content

fix(disks): restore disk from snapshot when storage rounds size up#2635

Draft
nevermarine wants to merge 1 commit into
mainfrom
fix/disks/restore-pvc-size-rounding
Draft

fix(disks): restore disk from snapshot when storage rounds size up#2635
nevermarine wants to merge 1 commit into
mainfrom
fix/disks/restore-pvc-size-rounding

Conversation

@nevermarine

Copy link
Copy Markdown
Collaborator

Description

Restoring a virtual disk (and therefore a virtual machine) from a snapshot fails on storage backends that round volume sizes up to a fixed granularity — for example Ceph RBD rounds up to whole GiB. The restored disk stays in the Failed phase with a ProvisioningFailed / "the specified pvc size is insufficient" error, and any VirtualMachineOperation restore that depends on it never reaches Completed.

It happens when the source disk was created without an explicit size: its volume is requested at the source image's virtual size, but the backend provisions a larger volume, so the snapshot's restore size ends up bigger than the size recorded in the snapshot metadata. On restore that smaller recorded size was rejected as insufficient. It is now treated as a lower bound and raised to the snapshot restore size, but only when the size was not explicitly set by the user (an explicit too-small user request is still rejected).

Why do we need it, and what problem does it solve?

On rounding storage backends (Ceph RBD is the common case) snapshot restore is effectively broken for any disk that was provisioned without an explicit size — the restored disk and the restore operation are stuck in Failed. This restores the ability to recover disks and VMs from snapshots on such storage.

What is the expected result?

Reproduction (on a Ceph RBD storage class):

  1. Create a VirtualDisk from a ClusterVirtualImage with spec.persistentVolumeClaim: {} (no size). The PVC is requested at the image virtual size but provisioned rounded up to the next GiB.
  2. Create a VirtualDiskSnapshot of it.
  3. Create a new VirtualDisk from that snapshot with no explicit size.

Before: the new disk goes to Failed (the specified pvc size is insufficient).
After: the new disk provisions at the snapshot restore size and becomes Ready; VMOP restore completes.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: disks
type: fix
summary: "Restoring a virtual disk or virtual machine from a snapshot no longer fails on storage that rounds volume sizes up (e.g. Ceph RBD)."

When a VirtualDisk is created without an explicit size, its PVC is requested
at the data source's virtual size. Storage backends that round volume sizes up
(e.g. Ceph RBD rounds to whole GiB) provision a larger volume, so the
VolumeSnapshot restore size exceeds the originally requested size stored in the
snapshot metadata.

On restore that stored original size was validated against the snapshot restore
size and rejected as insufficient, leaving the restored disk Failed and the
VirtualMachineOperation restore stuck in Failed.

Use the restore size as a lower bound when the size comes from the snapshot
metadata rather than an explicit user request.

Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant