-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vrg: cleanup rd when vrg is secondary #1738
Open
raghavendra-talur
wants to merge
4
commits into
RamenDR:main
Choose a base branch
from
raghavendra-talur:rtalur-fix-dr-disable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
vrg: cleanup rd when vrg is secondary #1738
raghavendra-talur
wants to merge
4
commits into
RamenDR:main
from
raghavendra-talur:rtalur-fix-dr-disable
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenamarMk
reviewed
Jan 7, 2025
@@ -566,5 +566,13 @@ func (v *VRGInstance) cleanupResources() error { | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few small comments on this change:
- The RD and RS terms in the function comment are misspelled, so this is a good opportunity to correct them.
- The object retrieved from
volSyncPVCs
is an actual PVC, while the one fromProtectedPVC
is not. This makes the variable namepvc
in the second loop misleading. Ideally, we should have namedProtectedPVC
asProtectedPVCInfo
, but it is what it is. - I would modify the function to look like the following, as we want to use the same function calls to delete the three resources in both cases:
func (v *VRGInstance) cleanupResources() error {
for idx := range v.volSyncPVCs {
pvc := &v.volSyncPVCs[idx]
if err := v.doCleanupResources(pvc.Name, pvc.Namespace); err != nil {
return err
}
}
for idx := range v.instance.Spec.VolSync.RDSpec {
protectedPVC := v.instance.Spec.VolSync.RDSpec[idx].ProtectedPVC
if err := v.doCleanupResources(protectedPVC.Name, protectedPVC.Namespace); err != nil {
return err
}
}
return nil
}
func (v *VRGInstance) doCleanupResources(name, namespace string) error {
if err := v.volSyncHandler.DeleteRS(name, namespace); err != nil {
return err
}
if err := v.volSyncHandler.DeleteRD(name, namespace); err != nil {
return err
}
if err := v.volSyncHandler.DeleteSnapshots(namespace); err != nil {
return err
}
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Updated as suggested!
raghavendra-talur
force-pushed
the
rtalur-fix-dr-disable
branch
from
January 9, 2025 02:13
f4af30f
to
dcbb587
Compare
BenamarMk
approved these changes
Jan 9, 2025
In processForDeletion, we cleanup the resources that are related to volsync. It relies on v.volSyncPVCs but the list is empty when the vrg is secondary because it is populated by looking at the vrg.status.ProtectedPVCs. For managed applications, the RD,RS and Snapshots were being as a consequence of the deletion of VRG as the VRG is the owner for them. In the case of discovered apps, the vrg is not the owner and therefore the RD was being left behind. Co-Authored-by: Annaraya Narasagond <[email protected]> Signed-off-by: Raghavendra Talur <[email protected]>
Co-Authored-by: Annaraya Narasagond <[email protected]> Signed-off-by: Raghavendra Talur <[email protected]>
if-return has been removed from the default list of revive for a valid reason. See the argument in mgechev/revive#843. Comparing two snippets 1. ``` if err := v.volSyncHandler.DeleteRS(name, namespace); err != nil { return err } if err := v.volSyncHandler.DeleteRD(name, namespace); err != nil { return err } if err := v.volSyncHandler.DeleteSnapshots(namespace); err != nil { return err } return nil ``` 2. ``` if err := v.volSyncHandler.DeleteRS(name, namespace); err != nil { return err } if err := v.volSyncHandler.DeleteRD(name, namespace); err != nil { return err } return v.volSyncHandler.DeleteSnapshots(namespace) ``` 1 is a lot easier to read compared to 2 but if-return throws an error for it. Signed-off-by: Raghavendra Talur <[email protected]>
Signed-off-by: Raghavendra Talur <[email protected]>
raghavendra-talur
force-pushed
the
rtalur-fix-dr-disable
branch
from
January 10, 2025 15:16
dcbb587
to
01f62e9
Compare
BenamarMk
approved these changes
Jan 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In processForDeletion, we cleanup the resources that are related to volsync. It relies on v.volSyncPVCs but the list is empty when the vrg is secondary because it is populated by looking at the vrg.status.ProtectedPVCs.
For managed applications, the RD,RS and Snapshots were being as a consequence of the deletion of VRG as the VRG is the owner for them.
In the case of discovered apps, the vrg is not the owner and therefore the RD was being left behind.