Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions examples/nvmeof/pvc-restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nvme-pvc-restore
spec:
storageClassName: csi-nvmeof-sc
dataSource:
name: nvme-pvc-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
9 changes: 9 additions & 0 deletions examples/nvmeof/snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: nvme-pvc-snapshot
spec:
volumeSnapshotClassName: csi-nvmeplugin-snapclass
source:
persistentVolumeClaimName: nvmeof-pvc
25 changes: 25 additions & 0 deletions examples/nvmeof/snapshotclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: csi-nvmeplugin-snapclass
driver: nvmeof.csi.ceph.com
deletionPolicy: Delete
parameters:
# String representing a Ceph cluster to provision storage snapshot from.
# Should be unique across all Ceph clusters in use for provisioning,
# cannot be greater than 36 bytes in length, and should remain immutable for
# the lifetime of the StorageClass in use.
# Ensure to create an entry in the configmap named ceph-csi-config, based on
# csi-config-map-sample.yaml, to accompany the string chosen to
# represent the Ceph cluster in clusterID below
clusterID: <cluster-id>

# Prefix to use for naming RBD snapshots (NVMe volumes are RBD-images).
# If omitted, defaults to "csi-snap-".
# snapshotNamePrefix: "foo-bar-"

csi.storage.k8s.io/snapshotter-list-secret-name: csi-nvme-secret
csi.storage.k8s.io/snapshotter-list-secret-namespace: default
csi.storage.k8s.io/snapshotter-secret-name: csi-nvme-secret
csi.storage.k8s.io/snapshotter-secret-namespace: default
34 changes: 34 additions & 0 deletions internal/nvmeof/controller/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,40 @@ func (cs *Server) ControllerExpandVolume(
return cs.backendServer.ControllerExpandVolume(ctx, req)
}

// CreateSnapshot forwards the snapshot creation to the backend RBD driver. Because Snapshots do not need to
// be available in the NVMe-oF gateway, there are no further actions needed.
func (cs *Server) CreateSnapshot(
ctx context.Context,
req *csi.CreateSnapshotRequest,
) (*csi.CreateSnapshotResponse, error) {
err := cs.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT)
if err != nil {
log.ErrorLog(ctx, "invalid create snapshot req: %v", err)

return nil, err
}

// create snapshot is handled by rbd backend server
return cs.backendServer.CreateSnapshot(ctx, req)
}

// DeleteSnapshot forwards the snapshot deletion to the backend RBD driver. Because Snapshots are not
// available in the NVMe-oF gateway, there are no further actions needed.
func (cs *Server) DeleteSnapshot(
ctx context.Context,
req *csi.DeleteSnapshotRequest,
) (*csi.DeleteSnapshotResponse, error) {
err := cs.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT)
if err != nil {
log.ErrorLog(ctx, "invalid delete snapshot req: %v", err)

return nil, err
}

// delete snapshot is handled by rbd backend server
return cs.backendServer.DeleteSnapshot(ctx, req)
}

// validateCreateVolumeRequest validates the incoming request for nvmeof.
// the rest of the parameters are validated by RBD.
func validateCreateVolumeRequest(req *csi.CreateVolumeRequest) error {
Expand Down
1 change: 1 addition & 0 deletions internal/nvmeof/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (d *nvmeofDriver) Run(conf *util.Config) {
csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
csi.ControllerServiceCapability_RPC_MODIFY_VOLUME,
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
})

cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
Expand Down