@@ -326,9 +326,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
326326 return true , snapshot , nil
327327
328328 case action .Matches ("patch" , "volumesnapshots" ):
329- snapshot := & crdv1.VolumeSnapshot {}
330329 action := action .(core.PatchAction )
331-
332330 // Check and bump object version
333331 storedSnapshot , found := r .snapshots [action .GetName ()]
334332 if found {
@@ -359,9 +357,10 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
359357 }
360358
361359 // Store the updated object to appropriate places.
362- r .snapshots [snapshot .Name ] = storedSnapshot
360+ r .snapshots [storedSnapshot .Name ] = storedSnapshot
363361 r .changedObjects = append (r .changedObjects , storedSnapshot )
364362 r .changedSinceLastSync ++
363+
365364 klog .V (4 ).Infof ("saved updated snapshot %s" , storedSnapshot .Name )
366365 return true , storedSnapshot , nil
367366
@@ -1253,6 +1252,10 @@ func testAddSnapshotFinalizer(ctrl *csiSnapshotCommonController, reactor *snapsh
12531252 return ctrl .addSnapshotFinalizer (test .initialSnapshots [0 ], true , true )
12541253}
12551254
1255+ func testAddSingleSnapshotFinalizer (ctrl * csiSnapshotCommonController , reactor * snapshotReactor , test controllerTest ) error {
1256+ return ctrl .addSnapshotFinalizer (test .initialSnapshots [0 ], false , true )
1257+ }
1258+
12561259func testRemoveSnapshotFinalizer (ctrl * csiSnapshotCommonController , reactor * snapshotReactor , test controllerTest ) error {
12571260 return ctrl .removeSnapshotFinalizer (test .initialSnapshots [0 ], true , true )
12581261}
@@ -1510,24 +1513,29 @@ func evaluateFinalizerTests(ctrl *csiSnapshotCommonController, reactor *snapshot
15101513 if funcName == "testAddSnapshotFinalizer" {
15111514 for _ , snapshot := range reactor .snapshots {
15121515 if test .initialSnapshots [0 ].Name == snapshot .Name {
1513- if ! utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) && utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1514- ! utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) && utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
1516+ if ! utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1517+ utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1518+ ! utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1519+ utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
15151520 klog .V (4 ).Infof ("test %q succeeded. Finalizers are added to snapshot %s" , test .name , snapshot .Name )
15161521 bHasSnapshotFinalizer = true
15171522 }
15181523 break
15191524 }
15201525 }
15211526 if test .expectSuccess && ! bHasSnapshotFinalizer {
1522- t .Errorf ("Test %q: failed to add finalizer to Snapshot %s" , test .name , test .initialSnapshots [0 ].Name )
1527+ t .Errorf ("Test %q: failed to add finalizer to Snapshot %s. Finalizers: %s " , test .name , test .initialSnapshots [0 ].Name , test . initialSnapshots [ 0 ]. GetFinalizers () )
15231528 }
15241529 }
15251530 bHasSnapshotFinalizer = true
15261531 if funcName == "testRemoveSnapshotFinalizer" {
15271532 for _ , snapshot := range reactor .snapshots {
15281533 if test .initialSnapshots [0 ].Name == snapshot .Name {
1529- if utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) && ! utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1530- utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) && ! utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
1534+ if utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1535+ ! utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer ) &&
1536+ utils .ContainsString (test .initialSnapshots [0 ].ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) &&
1537+ ! utils .ContainsString (snapshot .ObjectMeta .Finalizers , utils .VolumeSnapshotAsSourceFinalizer ) {
1538+
15311539 klog .V (4 ).Infof ("test %q succeeded. SnapshotFinalizer is removed from Snapshot %s" , test .name , snapshot .Name )
15321540 bHasSnapshotFinalizer = false
15331541 }
0 commit comments