@@ -101,13 +101,37 @@ func (s *snapshot) DeleteSnapshot(ctx context.Context, snapshotID string, snapsh
101
101
return nil
102
102
}
103
103
104
+ func (s * snapshot ) isListSnapshotsSupported (ctx context.Context ) (bool , error ) {
105
+ client := csi .NewControllerClient (s .conn )
106
+
107
+ capRsp , err := client .ControllerGetCapabilities (ctx , & csi.ControllerGetCapabilitiesRequest {})
108
+ if err != nil {
109
+ return false , err
110
+ }
111
+
112
+ for _ , cap := range capRsp .Capabilities {
113
+ if cap .GetRpc ().GetType () == csi .ControllerServiceCapability_RPC_LIST_SNAPSHOTS {
114
+ return true , nil
115
+ }
116
+ }
117
+
118
+ return false , nil
119
+ }
120
+
104
121
func (s * snapshot ) GetSnapshotStatus (ctx context.Context , snapshotID string ) (bool , time.Time , int64 , error ) {
105
122
client := csi .NewControllerClient (s .conn )
106
123
124
+ // If the driver does not support ListSnapshots, assume the snapshot ID is valid.
125
+ listSnapshotsSupported , err := s .isListSnapshotsSupported (ctx )
126
+ if err != nil {
127
+ return false , time.Time {}, 0 , fmt .Errorf ("failed to check if ListSnapshots is supported: %s" , err .Error ())
128
+ }
129
+ if ! listSnapshotsSupported {
130
+ return true , time.Time {}, 0 , nil
131
+ }
107
132
req := csi.ListSnapshotsRequest {
108
133
SnapshotId : snapshotID ,
109
134
}
110
-
111
135
rsp , err := client .ListSnapshots (ctx , & req )
112
136
if err != nil {
113
137
return false , time.Time {}, 0 , err
0 commit comments