@@ -41,11 +41,10 @@ import (
41
41
)
42
42
43
43
const (
44
- modifyPollInterval = 2 * time .Second
45
- setVACWaitPeriod = 30 * time .Second
46
- modifyingConditionSyncWaitPeriod = 2 * time .Minute
47
- modifyVolumeWaitPeriod = 10 * time .Minute
48
- vacCleanupWaitPeriod = 30 * time .Second
44
+ modifyPollInterval = 2 * time .Second
45
+ setVACWaitPeriod = 30 * time .Second
46
+ modifyVolumeWaitPeriod = 10 * time .Minute
47
+ vacCleanupWaitPeriod = 30 * time .Second
49
48
)
50
49
51
50
type volumeModifyTestSuite struct {
@@ -227,6 +226,46 @@ func (v *volumeModifyTestSuite) DefineTests(driver storageframework.TestDriver,
227
226
err = e2epv .WaitForPersistentVolumeClaimModified (ctx , f .ClientSet , l .resource .Pvc , modifyVolumeWaitPeriod )
228
227
framework .ExpectNoError (err , "While waiting for PVC to have expected VAC" )
229
228
})
229
+
230
+ ginkgo .It ("should recover from invalid target VAC by updating PVC to new valid VAC" , func (ctx context.Context ) {
231
+ init (ctx , false /* volume created without VAC */ )
232
+ ginkgo .DeferCleanup (cleanup )
233
+
234
+ // Create VAC with unsupported parameter
235
+ invalidVAC := MakeInvalidVAC (l .config )
236
+ _ , err := f .ClientSet .StorageV1beta1 ().VolumeAttributesClasses ().Create (ctx , invalidVAC , metav1.CreateOptions {})
237
+ framework .ExpectNoError (err , "While creating new VolumeAttributesClass" )
238
+ ginkgo .DeferCleanup (CleanupVAC , invalidVAC , f .ClientSet , vacCleanupWaitPeriod )
239
+
240
+ ginkgo .By ("Creating a pod with dynamically provisioned volume" )
241
+ podConfig := e2epod.Config {
242
+ NS : f .Namespace .Name ,
243
+ PVCs : []* v1.PersistentVolumeClaim {l .resource .Pvc },
244
+ SeLinuxLabel : e2epod .GetLinuxLabel (),
245
+ NodeSelection : l .config .ClientNodeSelection ,
246
+ ImageID : e2epod .GetDefaultTestImageID (),
247
+ }
248
+ pod , err := e2epod .CreateSecPodWithNodeSelection (ctx , f .ClientSet , & podConfig , f .Timeouts .PodStart )
249
+ ginkgo .DeferCleanup (e2epod .DeletePodWithWait , f .ClientSet , pod )
250
+ framework .ExpectNoError (err , "While creating pod for modifying" )
251
+
252
+ ginkgo .By ("Attempting to modify PVC via VolumeAttributeClass that contains unsupported parameters" )
253
+ newPVC := SetPVCVACName (ctx , l .resource .Pvc , invalidVAC .Name , f .ClientSet , setVACWaitPeriod )
254
+ l .resource .Pvc = newPVC
255
+ gomega .Expect (l .resource .Pvc ).NotTo (gomega .BeNil ())
256
+
257
+ ginkgo .By ("Waiting for modification to fail" )
258
+ err = e2epv .WaitForPersistentVolumeClaimModificationFailure (ctx , f .ClientSet , l .resource .Pvc , modifyVolumeWaitPeriod )
259
+ framework .ExpectNoError (err , "While waiting for PVC to have conditions" )
260
+
261
+ ginkgo .By ("Modifying PVC to new valid VAC" )
262
+ l .resource .Pvc = SetPVCVACName (ctx , l .resource .Pvc , l .vac .Name , f .ClientSet , setVACWaitPeriod )
263
+ gomega .Expect (l .resource .Pvc ).NotTo (gomega .BeNil ())
264
+
265
+ ginkgo .By ("Checking PVC status" )
266
+ err = e2epv .WaitForPersistentVolumeClaimModified (ctx , f .ClientSet , l .resource .Pvc , modifyVolumeWaitPeriod )
267
+ framework .ExpectNoError (err , "While waiting for PVC to have expected VAC" )
268
+ })
230
269
}
231
270
232
271
// SetPVCVACName sets the VolumeAttributesClassName on a PVC object
@@ -246,6 +285,15 @@ func SetPVCVACName(ctx context.Context, origPVC *v1.PersistentVolumeClaim, name
246
285
return patchedPVC
247
286
}
248
287
288
+ func MakeInvalidVAC (config * storageframework.PerTestConfig ) * storagev1beta1.VolumeAttributesClass {
289
+ return storageframework .CopyVolumeAttributesClass (& storagev1beta1.VolumeAttributesClass {
290
+ DriverName : config .GetUniqueDriverName (),
291
+ Parameters : map [string ]string {
292
+ "xxInvalidParameterKey" : "xxInvalidParameterValue" ,
293
+ },
294
+ }, config .Framework .Namespace .Name , "e2e-vac-invalid" )
295
+ }
296
+
249
297
func CleanupVAC (ctx context.Context , vac * storagev1beta1.VolumeAttributesClass , c clientset.Interface , timeout time.Duration ) {
250
298
gomega .Eventually (ctx , func () error {
251
299
return c .StorageV1beta1 ().VolumeAttributesClasses ().Delete (ctx , vac .Name , metav1.DeleteOptions {})
0 commit comments