@@ -281,8 +281,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
281
281
// currentTotalVols is the total number of volumes at a given time. It
282
282
// is used to verify that all the volumes have been listed.
283
283
currentTotalVols := 0
284
- // newVolIDs to keep a record of the newly created volume ids.
285
- var newVolIDs [ ]string
284
+ // newVols to keep a record of the newly created volume names and ids.
285
+ newVols := map [ string ]string {}
286
286
287
287
// Get the number of existing volumes.
288
288
vols , err := c .ListVolumes (
@@ -299,10 +299,10 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
299
299
300
300
By ("creating required new volumes" )
301
301
requiredVols := minVolCount - initialTotalVols
302
- name := "sanity"
303
302
for i := 1 ; i <= requiredVols ; i ++ {
303
+ name := "sanity" + strconv .Itoa (i )
304
304
req := & csi.CreateVolumeRequest {
305
- Name : name + strconv . Itoa ( i ) ,
305
+ Name : name ,
306
306
VolumeCapabilities : []* csi.VolumeCapability {
307
307
{
308
308
AccessType : & csi.VolumeCapability_Mount {
@@ -319,6 +319,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
319
319
vol , err := c .CreateVolume (context .Background (), req )
320
320
Expect (err ).NotTo (HaveOccurred ())
321
321
Expect (vol ).NotTo (BeNil ())
322
+ cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .Volume .VolumeId })
323
+ newVols [name ] = vol .Volume .VolumeId
322
324
}
323
325
324
326
// Update the current total vols count.
@@ -342,14 +344,15 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
342
344
if initialTotalVols < minVolCount {
343
345
344
346
By ("cleaning up deleting the volumes" )
345
- for _ , volID := range newVolIDs {
347
+ for name , volID := range newVols {
346
348
delReq := & csi.DeleteVolumeRequest {
347
349
VolumeId : volID ,
348
350
Secrets : sc .Secrets .DeleteVolumeSecret ,
349
351
}
350
352
351
353
_ , err := c .DeleteVolume (context .Background (), delReq )
352
354
Expect (err ).NotTo (HaveOccurred ())
355
+ cl .UnregisterVolume (name )
353
356
}
354
357
}
355
358
})
0 commit comments