Ensure PVC is deselected only when not in both VR and VS lists #2121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current deselection code checks if a PVC is part of VR PVC lists and if not invokes deselection. This was "assumed" safe as there was a finalizer check for the PVC to ensure it is protected by VR before progressing. This check was deep in the code, and was not applicable to PVCs that were marked for CG based protection. It was also not safe as it removed the PVC from the protectedPVC status unconditionally.
Further, if the PVC was part of VolSync protection, the above was unconditionally executed, and caused PVC protection issues for VolSync PVCs.
The fix provided, ensures that a PVC is NOT protected by either VolSync or VR based protection, before deselecting the same. Further it uses the VR finalizer on the PVC to determine of it was protected by VR or by VolSync to invoke the right deselection function.
Additional changes:
The envtests for deselect/delete of PVCs did not account for an eventual clause to wait for VRG to report that the PVC is no loner protected, before checking S3 for related contents to be absent. This is also fixed as part of this commit.