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

syncoid: Compare existing bookmarks #626

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

Conversation

0xFelix
Copy link
Contributor

@0xFelix 0xFelix commented Mar 14, 2021

When creating bookmarks compare the GUID of existing bookmarks before
failing the creation of a duplicate bookmark.

@0xFelix 0xFelix force-pushed the ignore-failed-create-bookmark branch 2 times, most recently from a478599 to 7e76de6 Compare April 23, 2023 10:25
@0xFelix
Copy link
Contributor Author

0xFelix commented Apr 23, 2023

@jimsalterjrs @phreaker0 Ping

@0xFelix 0xFelix force-pushed the ignore-failed-create-bookmark branch from 7e76de6 to 2979a7e Compare May 17, 2023 10:17
@0xFelix 0xFelix force-pushed the ignore-failed-create-bookmark branch from 2979a7e to fd449dd Compare July 27, 2023 12:28
@phreaker0
Copy link
Collaborator

I think a better way to handle this would be to check the bookmark on failure if it already exists and points to the correct snapshot and if not still fail. So there wouldn't be the need for an extra argument and one can be sure that the bookmark is correct.

When creating bookmarks compare the GUID of existing bookmarks before
failing the creation of a duplicate bookmark.

Signed-off-by: 0xFelix <felix@matouschek.org>
@0xFelix 0xFelix force-pushed the ignore-failed-create-bookmark branch from fd449dd to dd244de Compare April 20, 2024 16:37
@0xFelix 0xFelix changed the title Add option to ignore failed bookmark creation syncoid: Compare existing bookmarks Apr 20, 2024
@0xFelix
Copy link
Contributor Author

0xFelix commented Apr 20, 2024

@phreaker0 Makes sense! Updated the PR to implement that.

@0xFelix
Copy link
Contributor Author

0xFelix commented Apr 20, 2024

Also ping @jimsalterjrs

Comment on lines 839 to 843
if (defined $args{'create-bookmark'}) {
my $ret = createbookmark($sourcehost, $sourcefs, $newsyncsnap, $newsyncsnap);
my %existingbookmarks = getbookmarks($sourcehost,$sourcefs,$sourceisroot);
my $guid = $snaps{'source'}{$newsyncsnap}{'guid'};
my $ret = createbookmark($sourcehost, $sourcefs, $newsyncsnap, $newsyncsnap, $guid, %existingbookmarks);
$ret == 0 or do {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code should stay as it where before, because doing it this way will degrade performance because each time all the bookmarks needs to be listed.
It's better to handle that in the fallback case (if the bookmark creation fails), there the bookmark listing and the compare if this bookmark already exists should be made.

Comment on lines +1070 to +1075
my ($sourcehost, $sourcefs, $snapname, $bookmark, $guid, %existingbookmarks) = @_;

if (defined $existingbookmarks{$guid} && $existingbookmarks{$guid}{'name'} eq $bookmark) {
writelog('INFO', "bookmark already exists, skipping creation");
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be move to the fallback case if the bookmark creation failed

@@ -0,0 +1,93 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of #904 this needs to be renamed with a 0 prefix.

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.

None yet

2 participants