@@ -773,6 +773,39 @@ func (hp *hostPath) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReq
773
773
}, nil
774
774
}
775
775
776
+ func (hp * hostPath ) GetSnapshot (ctx context.Context , req * csi.GetSnapshotRequest ) (* csi.GetSnapshotResponse , error ) {
777
+ if err := hp .validateControllerServiceRequest (csi .ControllerServiceCapability_RPC_GET_SNAPSHOT ); err != nil {
778
+ klog .V (3 ).Infof ("invalid get snapshot req: %v" , req )
779
+ return nil , err
780
+ }
781
+
782
+ // Lock before acting on global state. A production-quality
783
+ // driver might use more fine-grained locking.
784
+ hp .mutex .Lock ()
785
+ defer hp .mutex .Unlock ()
786
+
787
+ // case 1: SnapshotId is not empty, return snapshots that match the snapshot id,
788
+ // none if not found.
789
+ if len (req .GetSnapshotId ()) == 0 {
790
+ }
791
+
792
+ snapshotID := req .SnapshotId
793
+ snapshot , err := hp .state .GetSnapshotByID (snapshotID )
794
+ if err != nil {
795
+ return nil , status .Errorf (codes .NotFound , "Snapshot with ID %q not found: %v" , snapshotID , err )
796
+ }
797
+
798
+ return & csi.GetSnapshotResponse {
799
+ Snapshot : & csi.Snapshot {
800
+ SnapshotId : snapshot .Id ,
801
+ SourceVolumeId : snapshot .VolID ,
802
+ CreationTime : snapshot .CreationTime ,
803
+ SizeBytes : snapshot .SizeBytes ,
804
+ ReadyToUse : snapshot .ReadyToUse ,
805
+ },
806
+ }, nil
807
+ }
808
+
776
809
func (hp * hostPath ) ControllerExpandVolume (ctx context.Context , req * csi.ControllerExpandVolumeRequest ) (* csi.ControllerExpandVolumeResponse , error ) {
777
810
if ! hp .config .EnableVolumeExpansion {
778
811
return nil , status .Error (codes .Unimplemented , "ControllerExpandVolume is not supported" )
@@ -878,6 +911,7 @@ func (hp *hostPath) getControllerServiceCapabilities() []*csi.ControllerServiceC
878
911
csi .ControllerServiceCapability_RPC_GET_CAPACITY ,
879
912
csi .ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT ,
880
913
csi .ControllerServiceCapability_RPC_LIST_SNAPSHOTS ,
914
+ csi .ControllerServiceCapability_RPC_GET_SNAPSHOT ,
881
915
csi .ControllerServiceCapability_RPC_LIST_VOLUMES ,
882
916
csi .ControllerServiceCapability_RPC_CLONE_VOLUME ,
883
917
csi .ControllerServiceCapability_RPC_VOLUME_CONDITION ,
0 commit comments