Skip to content

Commit 5868309

Browse files
committed
Prevent plugin from returning in-use error for source volumes
This addresses a regression in [1] causing plugins to return an in-use error (FAILED_PRECONDITION) when a sourcing resource (i.e., a snapshot or a volume) is deleted before the sourced volume is. [1]: kubernetes-csi#261
1 parent 0ddc0e0 commit 5868309

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/sanity/controller.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,14 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
587587
},
588588
},
589589
}
590-
_, err := r.CreateVolume(context.Background(), vol2Req)
590+
volume2, err := r.CreateVolume(context.Background(), vol2Req)
591+
Expect(err).NotTo(HaveOccurred())
592+
593+
// Clean up sourced volume first to prevent plugin from returning an
594+
// in-use error.
595+
By("cleaning up deleting the volume created from snapshot")
596+
delVol2Req := MakeDeleteVolumeReq(sc, volume2.GetVolume().GetVolumeId())
597+
_, err = r.DeleteVolume(context.Background(), delVol2Req)
591598
Expect(err).NotTo(HaveOccurred())
592599
})
593600

@@ -633,7 +640,14 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
633640
},
634641
},
635642
}
636-
_, err := r.CreateVolume(context.Background(), vol2Req)
643+
volume2, err := r.CreateVolume(context.Background(), vol2Req)
644+
Expect(err).NotTo(HaveOccurred())
645+
646+
// Clean up sourced volume first to prevent plugin from returning an
647+
// in-use error.
648+
By("cleaning up deleting the volume created from source volume")
649+
delVol2Req := MakeDeleteVolumeReq(sc, volume2.GetVolume().GetVolumeId())
650+
_, err = r.DeleteVolume(context.Background(), delVol2Req)
637651
Expect(err).NotTo(HaveOccurred())
638652
})
639653

0 commit comments

Comments
 (0)