-
Notifications
You must be signed in to change notification settings - Fork 59
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
Prune old VolumeSnapshots during replication destination reconciliation #1828
base: main
Are you sure you want to change the base?
Conversation
return 1 | ||
}) | ||
|
||
for i := 0; i < len(snapList.Items)-1; i++ { |
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.
(nit) It would be nice to extract this block and the one below into a reusable utility function that deletes a given list of objects. We are deleting a list of snapshots in two different places, one with n-1
items and the other with n
items.
ramen/internal/controller/volsync/vshandler.go
Lines 1125 to 1137 in ca44e13
for i := range snapList.Items { | |
snapshot := snapList.Items[i] | |
if err := v.client.Delete(v.ctx, &snapshot); err != nil { | |
if !errors.IsNotFound(err) { | |
v.log.Error(err, "Error cleaning up VolumeSnapshot", "name", snapshot.GetName()) | |
return err | |
} | |
} | |
v.log.Info("Deleted VolumeSnapshot", "name", snapshot.GetName()) | |
} |
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.
Helper function for deletion of snapshot list added, no more duplicated code.
Signed-off-by: Elena Gershkovich <[email protected]>
Fixes: https://issues.redhat.com/browse/DFBUGS-990
Volsync is leaving behind one snapshot per failover/relocate action, and it causes severe memory problems. The solution is to prune old VolumeSnapshots upon reconciliation of replication destination and leave only one latest VolumeSnapshot, deleting older ones.