Skip to content

Creating Volumes from Snapshots should be (almost) instant #309

@cometship

Description

@cometship

Correct me if I'm wrong, but shouldn't Volume creation be (almost) instant when they are created from Snapshots (with COW supported)?

Because now I can't use Velero to create PVC Backups (Velero creates PVC referencing Snapshot), as it copies the Snapshot image (created instantly) byte-for-byte over to a new image file, which just takes too long. I thought it would just do cp --reflink=always snap.img restored.img.

See:

def restore_snapshot(
self, volume_id: str, name: str, destination: Path, temporary: bool = False
):
"""Restore a snapshot"""
chunk_size = 1024 * 1024
snap_path = self._get_snapshot_path(volume_id, name, temporary)
with open(snap_path, "rb") as src, open(destination, "wb") as dst:
while True:
buf = src.read(chunk_size)
if not buf:
break
dst.write(buf)
dst.flush()
fsync(dst.fileno())

Used here:
snapshot_manager.restore_snapshot(
source_volume_id,
snapshot_name,
img_file,
source_type == VolumeSource.volume,
)

Metadata

Metadata

Assignees

Labels

kind/improvementCategorizes issue or PR as related to improving upon a current feature

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions