Skip to content

Commit 7fa3701

Browse files
committed
nvmeof: add volume cloning capability
enable volume cloning support for nvmeof CSI driver by declaring CLONE_VOLUME capability. The RBD backend automatically handles all clone operations (snapshot-to-volume restore and volume-to-volume cloning) when VolumeContentSource is present in CreateVolume request. The NVMeoF driver adds debug logging to track clone operations and creates namespaces pointing to the cloned RBD images. No changes to the NVMeoF gateway are required since clones are transparent at the block device level. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
1 parent 9912f67 commit 7fa3701

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

internal/nvmeof/controller/controllerserver.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,22 @@ func (cs *Server) CreateVolume(
118118
}
119119
defer cs.volumeLocks.Release(req.GetName())
120120

121+
// Extract clone source if present (for debug logging)
122+
if contentSource := req.GetVolumeContentSource(); contentSource != nil {
123+
switch contentSource.GetType().(type) {
124+
case *csi.VolumeContentSource_Snapshot:
125+
if snapshot := contentSource.GetSnapshot(); snapshot != nil {
126+
log.DebugLog(ctx, "Creating volume from snapshot: %s", snapshot.GetSnapshotId())
127+
}
128+
case *csi.VolumeContentSource_Volume:
129+
if vol := contentSource.GetVolume(); vol != nil {
130+
log.DebugLog(ctx, "Creating volume clone from volume: %s", vol.GetVolumeId())
131+
}
132+
}
133+
}
134+
121135
// Step 1: Create RBD volume through backend. if exists, it is ok.
136+
// RBD backend automatically handles cloning when VolumeContentSource is present.
122137
res, err := cs.backendServer.CreateVolume(ctx, req)
123138
if err != nil {
124139
log.ErrorLog(ctx, "failed to create RBD volume: %v", err)

internal/nvmeof/driver/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (d *nvmeofDriver) Run(conf *util.Config) {
6666
csi.ControllerServiceCapability_RPC_MODIFY_VOLUME,
6767
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
6868
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
69+
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
6970
})
7071

7172
cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{

0 commit comments

Comments
 (0)