@@ -140,7 +140,8 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
140
140
volumeID := req .VolumeId
141
141
resourceGroupName , accountName , containerName , err := getContainerInfo (volumeID )
142
142
if err != nil {
143
- return nil , err
143
+ klog .Errorf ("getContainerInfo(%s) in DeleteVolume failed with error: %v" , volumeID , err )
144
+ return & csi.DeleteVolumeResponse {}, nil
144
145
}
145
146
146
147
if resourceGroupName == "" {
@@ -179,7 +180,36 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
179
180
return nil , status .Error (codes .InvalidArgument , "Volume capabilities missing in request" )
180
181
}
181
182
182
- // todo: we may check file share existence here
183
+ volumeID := req .VolumeId
184
+ resourceGroupName , accountName , containerName , err := getContainerInfo (volumeID )
185
+ if err != nil {
186
+ klog .Errorf ("getContainerInfo(%s) in ValidateVolumeCapabilities failed with error: %v" , volumeID , err )
187
+ return nil , status .Error (codes .NotFound , err .Error ())
188
+ }
189
+
190
+ if resourceGroupName == "" {
191
+ resourceGroupName = d .cloud .ResourceGroup
192
+ }
193
+
194
+ accountKey , err := GetStorageAccesskey (d .cloud , accountName , resourceGroupName )
195
+ if err != nil {
196
+ return nil , fmt .Errorf ("no key for storage account(%s) under resource group(%s), err %v" , accountName , resourceGroupName , err )
197
+ }
198
+
199
+ client , err := azstorage .NewBasicClientOnSovereignCloud (accountName , accountKey , d .cloud .Environment )
200
+ if err != nil {
201
+ return nil , err
202
+ }
203
+ blobClient := client .GetBlobService ()
204
+ container := blobClient .GetContainerReference (containerName )
205
+
206
+ exist , err := container .Exists ()
207
+ if err != nil {
208
+ return nil , err
209
+ }
210
+ if ! exist {
211
+ return nil , status .Error (codes .NotFound , "the requested volume does not exist" )
212
+ }
183
213
184
214
// blobfuse supports all AccessModes, no need to check capabilities here
185
215
return & csi.ValidateVolumeCapabilitiesResponse {Message : "" }, nil
0 commit comments