Repository navigation
PowerFlex: support creating a volume from a volume snapshot - #14842
Open
DRDAVIDBANNER wants to merge 3 commits into
Open
DRDAVIDBANNER wants to merge 3 commits into
DRDAVIDBANNER wants to merge 3 commits into
Conversation
Creating a volume from a snapshot of a volume on a PowerFlex/ScaleIO pool
was refused by the API ("Create volume from snapshot is not supported for
PowerFlex volume snapshots"). The refusal guarded a real gap: the driver
advertises CAN_CREATE_VOLUME_FROM_SNAPSHOT, so StorageSystemDataMotionStrategy
creates the new volume with the "cloneOfSnapshot" volume detail and, on KVM,
expects the driver to fill it; the PowerFlex driver ignored the detail and
created an empty volume.
ScaleIOPrimaryDataStoreDriver.createVolume now honours "cloneOfSnapshot":
after creating the new PowerFlex volume it maps the snapshot and the new
volume to the SDC of a KVM host and copies the data with a CopyCommand
(the agent's existing PowerFlex primary-to-primary copy). The new volume is
independent of the source volume's VTree (its own lifecycle, migrations and
VTree snapshot limit). Both are unmapped afterwards; if the copy fails, the
new PowerFlex volume is removed and the job fails with the cause. Creating
an encrypted volume from a snapshot, or onto a different pool than the
snapshot's, is refused with a clear error.
The API check is removed, and the Marvin smoke test no longer expects it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With snapshot.backup.to.secondary=false, VolumeOrchestrator.createVolumeFromSnapshot
tries to back up a KVM snapshot that is kept only on primary storage to
secondary storage first. For a PowerFlex snapshot that backup is a no-op
(StorageSystemSnapshotStrategy keeps it on primary), so the lookup of the
secondary copy then fails ("Could not find snapshot [..] in Image storage")
and the job fails with error 530.
The PowerFlex driver creates the volume from its snapshot on the pool itself,
so for snapshots on a PowerFlex pool the orchestrator now skips the staging
and uses the snapshot on primary storage, as it already does when
snapshot.backup.to.secondary=true. Other storage types are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Before creating anything on PowerFlex, check that the snapshot is on the same pool and that neither the new volume nor the snapshot's volume is encrypted; refuse the same up front in createVolume and in deployVirtualMachine with a snapshot (other zone, encryption), after the access check. - Send the snapshot to the agent as RAW: a PowerFlex snapshot is a raw block device, whatever format the volume record says. - Copy host: a host the pool is attached to, then eligible KVM hosts (storage access groups, enabled clusters not excluded from storage operations, the pool's cluster for cluster-scoped pools); up to three are tried. With on-demand SDC connection the pool attachment is removed when nothing is mapped, so the copy must not depend on it. - Serialize copies from the same snapshot on the same host with a GlobalLock taken before the SDC is prepared; unmap the snapshot only if this copy mapped it; release an SDC a copy prepared but did not use. - On failure, remove the new PowerFlex volume, clear its identifiers, release its used bytes only if the removal succeeded, else raise a storage alert; deleteAsync treats a volume without a PowerFlex volume as nothing to delete. - Allocate a volume from a PowerFlex snapshot on the snapshot's pool only. - Move the snapshot staging decision of createVolumeFromSnapshot into prepareSnapshotForVolumeCreation (unchanged for other storage). - Tests: driver, SnapshotHelper, VolumeOrchestrator unit tests; Marvin test_13 (data check of a volume from a snapshot) and test_14 (deploy an Instance from a ROOT volume snapshot). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DRDAVIDBANNER
marked this pull request as ready for review
November 24, 2026 20:57
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Creating a volume from a snapshot of a volume on a PowerFlex/ScaleIO pool is refused today:
createVolumewithsnapshotidfails with "Create volume from snapshot is not supported for PowerFlex volumesnapshots". The check has been in
VolumeApiServiceImplsince the plugin was added (#4304). It blocks creating a newvolume from an existing volume snapshot (for example, to recover files, or for backup tools that clone a volume from a
snapshot to read it). Reverting a volume to a snapshot already works and is unchanged.
This PR makes it work and keeps the new volume independent of the source volume.
Why the API check existed, and why removing it is not enough. The PowerFlex driver advertises
CAN_CREATE_VOLUME_FROM_SNAPSHOTandSTORAGE_SYSTEM_SNAPSHOT, so a snapshot → volume copy goes toStorageSystemDataMotionStrategy.handleCreateManagedVolumeFromManagedSnapshot. That method creates the volume withthe volume detail
cloneOfSnapshot=<snapshot id>and, on KVM, copies nothing: it expects the driver to fill thevolume (SolidFire, Datera and Linstor do this in their
createVolume). The PowerFlex driver ignored the detail:createVolume"succeeds" and returns an empty volume (reproduced, see testing);deployVirtualMachinewithsnapshotid, which does not go through that API check, has the same problem today: thenew Instance gets an empty ROOT volume.
Changes
Driver (
ScaleIOPrimaryDataStoreDriver), so that the volume is filled:createVolumehonourscloneOfSnapshot. Before anything is created on PowerFlex, it checks:After creating the new PowerFlex volume it copies the snapshot into it through a KVM host:
groups, enabled clusters not excluded from storage operations, the pool's cluster for cluster-scoped pools). Up to
three are tried, until one has a usable SDC. With on-demand SDC connection a host's attachment to the pool is
removed when nothing is mapped to its SDC, so the copy can't rely on it.
CopyCommandruns the agent'sexisting PowerFlex primary-to-primary copy (
copyVolumeFromPrimaryToPrimary,qemu-img convert). The source isalways sent as RAW: a PowerFlex snapshot is a raw block device, whatever format the volume record says.
operation). The unmap is best effort, as in
revokeAccess. If the copy mapped nothing, the host's SDC is releasedwhen nothing else is mapped to it, as
revokeAccessdoes.Lock: copies from the same snapshot on the same host are serialized with a
GlobalLock, taken before the SDC isprepared. One such copy therefore can't unmap the snapshot, or release the SDC, while another one is preparing or
reading it.
for
grantAccess/revokeAccesstoday. If they overlap, either side can fail, cleanly.from different snapshots on the same host are not serialized with each other.
Failure: if the copy fails (no host or SDC, a mapping failure, an agent error, or no answer), the new PowerFlex
volume is removed, its identifiers are cleared from the volume row, and the operation fails with the cause (the
createVolume job, or the deployVirtualMachine call).
PowerFlex volume to remove by hand.
detail, not the new lock).
deleteAsynctreats a volume with no PowerFlex volume as nothing to delete. Without that, deleting the failedvolume row with the
deleteVolumeAPI failed ("Volume id cannot be null"), as seen in testing.tried; after the copy has started it is not retried.
Why a copy and not a PowerFlex snapshot of the snapshot: a PowerFlex snapshot belongs to the volume tree (VTree)
of its source volume, and so would a snapshot of it. Such a volume would share the source's VTree, which brings two
problems:
migrateVTreeand vice versa, somigrateVolumeof one silently moves the other.A copy gives an ordinary, independent volume. A PowerFlex-native "fast clone" could be an opt-in follow-up.
Server and orchestration, so that it is allowed:
VolumeApiServiceImpl: the PowerFlex refusal is removed. For a snapshot on a PowerFlex pool, two requests are nowrefused synchronously, after the access check (
SnapshotHelper#validateVolumeFromSnapshotOnStorageCreatingVolumes):UserVmManagerImpl(deployVirtualMachinewithsnapshotid) makes the same checks before the Instance isallocated, with the root disk offering and
rootdiskkmskeyid. Both paths also refuse a snapshot of an encryptedvolume up front.
As before this PR,
deployVirtualMachinewithsnapshotidcreates the ROOT volume during the synchronous part ofthe API call. On PowerFlex that now includes the data copy, so a large snapshot can take minutes; API clients
should allow for it.
VolumeOrchestrator.createVolumeFromSnapshot: a volume from a PowerFlex snapshot is allocated on the snapshot'spool only (
avoidPoolsOtherThanRequiredForSnapshot, which avoids the zone's other pools). Without this, the allocatorcould pick another pool with matching tags (another PowerFlex pool, or a non-managed pool), and the job would fail
late.
With
snapshot.backup.to.secondary=false, the orchestrator first tries to stage a KVM snapshot that is only onprimary storage onto secondary storage. For a PowerFlex snapshot that backup is a no-op (
StorageSystemSnapshotStrategykeeps it on primary), and the lookup of the secondary copy then failed ("Could not find snapshot [..] in Image
storage", error 530).
snapshot.backup.to.secondary=true.prepareSnapshotForVolumeCreation, and is unchanged for other storage.The orchestration changes are limited to PowerFlex (
SnapshotHelper#isSnapshotOnStorageCreatingVolumesFromIt,#getStoragePoolIdRequiredToCreateVolumeFromSnapshot,#validateVolumeFromSnapshotOnStorageCreatingVolumes). Not everydriver that advertises
CAN_CREATE_VOLUME_FROM_SNAPSHOTfills a volume created withcloneOfSnapshot, so otherstorage types are unchanged. A driver capability could replace the pool-type list later.
Marvin:
test_snapshots.pyno longer expects the refusal on PowerFlex;test_scaleio_volumes.py::test_13_create_volume_from_snapshot_keeps_the_datawrites data, takes a snapshot,overwrites the data, creates a volume from the snapshot and compares checksums in the Instance. It needs SSH to the
Instance (the suite's prerequisites say so) and skips without it;
test_14_deploy_vm_from_root_volume_snapshotdeploys an Instance from a ROOT volume snapshot.I have not run the Marvin tests: there was no PowerFlex Marvin environment, see testing.
No agent changes: the management server reuses an existing agent copy path. Mixed versions are fine, and it works
with 4.22 agents unchanged.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests (all pass):
ScaleIOPrimaryDataStoreDriverVolumeFromSnapshotTest(new, 40 tests) covers:cloneOfSnapshotlookup, and the up-front refusals (snapshot not on primary, on another pool, an encryptednew or source volume by passphrase or KMS key, a missing source volume record), before any PowerFlex call;
CopyCommandwith a RAW source and the managed-volume TOs, unmap, all underthe per-snapshot, per-host lock; an existing snapshot mapping is left in place;
the new volume and releases an idle SDC; a removal failure keeps the used bytes and raises an alert;
the next host only when the copy has not started;
deleteAsyncof a volume without a PowerFlex volume, andcreateVolumewith and without the detail.SnapshotHelperTest(pool-type checks, required pool, up-front validation),VolumeOrchestratorTest(pool pinning, staging skipped for PowerFlex only) and
VolumeApiServiceImplTest/UserVmManagerImplTest(thevalidation is called on both paths).
VolumeApiServiceImplTest(168),UserVmManagerImplTest(278),VolumeOrchestratorTest(53) andSnapshotHelperTest(35).Lab testing. No PowerFlex hardware was available, so the management server and KVM agent talked to a PowerFlex
gateway REST simulator:
ScaleIOGatewayClientImplmakes: login/token, systems, pools,volumes,
snapshotVolumes, SDC mapping, stats andoverwriteVolumeContent.drv_cfgandsciniand the/dev/disk/by-id/emc-vol-<system>-<volume>devices, so the KVM agent ran unmodified.
ScaleIOGatewayClientImplpassed 34 API checks against the simulator.The setup was CloudStack 4.22.1.1: management server and KVM agent on Ubuntu 24.04, an Advanced zone, and the pool
added as PowerFlex (zone-wide, tagged). The management server ran 4.22.1.1 with this PR's changes backported (the
KMS checks left out, as 4.22 has no KMS); the agent was unchanged. Each check wrote a known pattern to a volume of a
running Instance, took a volume snapshot, then overwrote the volume.
Before this PR:
createVolume(snapshotid)deployVirtualMachine(snapshotid)of a ROOT snapshotcreateVolume(snapshotid)snapshot.backup.to.secondary=falsecreateVolume(snapshotid)With this PR, every group was run with
snapshot.backup.to.secondarytrue and false:createVolumewith only name, zoneid and snapshotid; attach, read, detach (unmapped), delete (removed from PowerFlex); snapshot keptqemu-img convertfails: the job fails with the agent's error, no orphan PowerFlex volume, snapshot unmapped, record not Ready and expungeable, source intact, retry succeedscreateVolumefrom one snapshot at once (serialized by the lock): both succeed, both hold the snapshot data, the snapshot is unmapped after bothdeployVirtualMachine(snapshotid, startvm=false): the new ROOT equals the snapshot before the first boot, and the Instance startsIn total, 65/65 checks passed with each setting, in one run on the final code. Two timing defects of the simulator's SDC
stand-in turned up while testing (NBD device reuse, and an unmap that stopped the export before the host had
released the device) and made back-to-back copies fail. Both were fixed in the simulator before that run.
End to end with an external backup tool. It backs up through the CloudStack API, with
snapshot.backup.to.secondary=false, an Instance whose ROOT and DATA volumes are both on the PowerFlex pool, and an ext4 file system with known files on the DATA volume. Two backups were taken, with files changed in between. For each volume, CloudStack ran:createSnapshot,createVolume(snapshotid)(the copy in this PR), attach to the tool's appliance Instance, detach,deleteVolume,deleteSnapshot.I have not run the Marvin tests: there was no PowerFlex Marvin environment.
How did you try to break this feature and the system with this change?
both are unmapped (
finally). The job fails with the reason, and the volume record ends in Destroy.any change on PowerFlex (synchronously in the API for
createVolumeanddeployVirtualMachine).snapshot is unmapped afterwards.
after it.
snapshot.backup.to.secondarytrue and false: both work; the staging change is limited to PowerFlex.Not covered (possible follow-ups):
snapshot.backup.to.secondary=falsegoes through the samestaging in
TemplateManagerImpland probably fails in the same way. It is unchanged here and was not tested.🤖 Generated with Claude Code