Skip to content

Commit bfeaddb

Browse files
committed
rbd: implement GetSnapshot CSI procedure
See-also: container-storage-interface/spec#586 Signed-off-by: Niels de Vos <[email protected]>
1 parent c761b98 commit bfeaddb

File tree

7 files changed

+1400
-1171
lines changed

7 files changed

+1400
-1171
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19
1616
github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000
1717
github.com/ceph/go-ceph v0.33.0
18-
github.com/container-storage-interface/spec v1.11.0
18+
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41
1919
github.com/csi-addons/kubernetes-csi-addons v0.12.0
2020
github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5
2121
github.com/gemalto/kmip-go v0.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
157157
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
158158
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
159159
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
160-
github.com/container-storage-interface/spec v1.11.0 h1:H/YKTOeUZwHtyPOr9raR+HgFmGluGCklulxDYxSdVNM=
161-
github.com/container-storage-interface/spec v1.11.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
160+
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41 h1:7+UfUxukJlnEVGALQzUcCYXP/ISyS/VZJ7DPpAQxROY=
161+
github.com/container-storage-interface/spec v1.11.1-0.20250515121015-a539b4f9fe41/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
162162
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
163163
github.com/csi-addons/kubernetes-csi-addons v0.12.0 h1:RbF2dCjWV4ljynibEOkA0wbwwt/09awjOKgEFC14Bns=
164164
github.com/csi-addons/kubernetes-csi-addons v0.12.0/go.mod h1:8vrXJUZrlI2ms2aZ6qRfp8ieRlpHEefTX5azOFi67o0=

internal/rbd/controllerserver.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,3 +1709,27 @@ func (cs *ControllerServer) ControllerUnpublishVolume(
17091709

17101710
return &csi.ControllerUnpublishVolumeResponse{}, nil
17111711
}
1712+
1713+
func (cs *ControllerServer) GetSnapshot(
1714+
ctx context.Context,
1715+
req *csi.GetSnapshotRequest,
1716+
) (*csi.GetSnapshotResponse, error) {
1717+
mgr := NewManager(cs.Driver.GetInstanceID(), nil, req.GetSecrets())
1718+
defer mgr.Destroy(ctx)
1719+
1720+
snapID := req.GetSnapshotId()
1721+
snapshot, err := mgr.GetSnapshotByID(ctx, snapID)
1722+
if err != nil {
1723+
return nil, status.Errorf(codes.NotFound, "failed to find snapshot with ID %q: %s", snapID, err.Error())
1724+
}
1725+
defer snapshot.Destroy(ctx)
1726+
1727+
csiSnap, err := snapshot.ToCSI(ctx)
1728+
if err != nil {
1729+
return nil, status.Error(codes.Internal, err.Error())
1730+
}
1731+
1732+
return &csi.GetSnapshotResponse{
1733+
Snapshot: csiSnap,
1734+
}, nil
1735+
}

internal/rbd/driver/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func (r *Driver) Run(conf *util.Config) {
112112
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
113113
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
114114
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
115+
csi.ControllerServiceCapability_RPC_GET_SNAPSHOT,
115116
})
116117
// We only support the multi-writer option when using block, but it's a supported capability for the plugin in
117118
// general

0 commit comments

Comments
 (0)