Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ELENAGER
Copy link
Member

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.

@ELENAGER ELENAGER changed the title Prune old snapshots during reconcile replication destination Prune old VolumeSnapshots during replication destination reconciliation Feb 13, 2025
return 1
})

for i := 0; i < len(snapList.Items)-1; i++ {
Copy link
Member

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.

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())
}

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants