@@ -180,7 +180,36 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
180
180
return nil , status .Error (codes .InvalidArgument , "Volume capabilities missing in request" )
181
181
}
182
182
183
- // 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
+ }
184
213
185
214
// blobfuse supports all AccessModes, no need to check capabilities here
186
215
return & csi.ValidateVolumeCapabilitiesResponse {Message : "" }, nil
0 commit comments