Skip to content

bisync: bug fixes and new features including --create-empty-src-dirs and equality check - #6971

Merged
ncw merged 9 commits into
rclone:masterfrom
nielash:bisync-fixes-and-features
Aug 12, 2023
Merged

ncw merged 9 commits into
rclone:masterfrom
nielash:bisync-fixes-and-features

Conversation

@nielash

@nielash nielash commented Apr 23, 2023 •

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Several bisync bug fixes and new features including --create-empty-src-dirs and equality check.
Described in (excruciating) detail here. And further articulated in the proposed documentation changes.

In summary:

Was the change discussed in an issue or in the forum before?

Yes, mainly in this forum post:
https://forum.rclone.org/t/bisync-bugs-and-feature-requests/37636

It also fixes #6109 and addresses several other open issues: #6841 #5683 #5681 #5676 #5675 #5674

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@nielash
nielash marked this pull request as ready for review April 23, 2023 16:54
@ncw

ncw commented Apr 24, 2023

Copy link
Copy Markdown
Member

Would it be possible to break this down into a commit per fix/feature?

If the commit messages can link to either the forum or an rclone issue as well that would be perfect.

Reviewing a lot of changes all at once is very difficult :-(

I don't mind receiving this all as one pull request with lots of commits, but I'd suggest you start with a PR with one or a few of the simple fixes so we can get into the swing of things.

@nielash

nielash commented Apr 24, 2023

Copy link
Copy Markdown
Contributor Author

Sure thing, sorry about that 😃

Btw, it looks like a lot more than it is, because the vast majority is docs and test file changes.

Also the tests all pass locally...looks like they are failing on GH because the test.log files got gitignored out of the golden directory. Will fix and resubmit. 😃

@nielash
nielash marked this pull request as draft April 24, 2023 12:13
@nielash

nielash commented Apr 24, 2023

Copy link
Copy Markdown
Contributor Author

Ok I broke this down into a commit per fix/feature and confirmed the GitHub tests are passing now.

Note that I left all the test changes together in one commit: e1e5593 I don't think it's really possible to separate them due to the way the Bisync test suite is designed (it diffs an actual log with a golden log, so just about any unrelated change you make will cause false positives. I could make them each pass separately, but then they might not all pass together.)

If you want to start with just a few, I think these are the most important:

But these are the simplest:

@nielash
nielash marked this pull request as ready for review April 24, 2023 17:57
@ncw

ncw commented May 9, 2023

Copy link
Copy Markdown
Member

Sorry for the delay looking at this! I'd like to merge this for the v1.63 release if possible (in about 2 weeks).

I'll review the code tomorrow and we can start the merge process - thank you.

@ncw ncw added this to the v1.63 milestone May 9, 2023

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I ignored the first two commits - the commit and the revert and I've written inline comments.

In an ideal world in each commit we'd have

  • the code change
  • the commit message telling us why we changed it with before and after
    • So you'd edit what you wrote in the forum and put it as a commit message
    • Then describe how your changes fix that problem
  • doc changes relevant to the commit
  • test changes relevant to the commit

That then gives us nice easy units to review, apply and revert if necessary, so if we find a bug in one of the commits we can revert it and the docs and the tests. The code should compile and pass its tests for every commit - if it doesn't this makes using git bisect much harder.

Currently the docs and tests are all in a different commit which would make reverting one of the commits very hard.

Would it be possible to re-arrange the commits like that? I realize that re-arranging the tests will be quite annoying

I think the itself code looks OK but I have some efficiency worries about use of NewObject which I've made inline comments about.

I think the "create-empty-dirs and equality check" commit probably needs re-working.

Thank you for taking this on - much appreciated.

Comment thread .gitignore Resolved
Comment thread docs/content/bisync.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you render the html bold/italic in markdown please? The markdown converter is set to ignore HTML in markdown so these won't render properly on the website.

This is so we can easily turn the markdown into other things like man pages.

There are a few of them in this doc which I haven't marked individually.

Note this section in the Makefile

rclone/Makefile

Lines 157 to 160 in fcf47a8

website:
rm -rf docs/public
cd docs && hugo
@if grep -R "raw HTML omitted" docs/public ; then echo "ERROR: found unescaped HTML - fix the markdown source" ; fi

Comment thread docs/content/bisync.md Resolved
Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note that NewObject can be quite expensive on some backends.

For example running NewObject on every file in a directory might list the directory once for each object, whereas if you run List on a directory you can create all the objects at once.

I think here it will only happen occasionally won't it so it is probably OK?

Comment thread cmd/bisync/listing.go Resolved
Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This debug should have the error message in "...: %v", direrr)

Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a better way of working out which paths are directories here? This is a very expensive way of doing it and NewObject doesn't always return fs.ErrorIsDir (eg on the bucket based backends such as S3).

Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Duplicate code block - factor out into createDirs function?

Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same comments as above!

Comment thread cmd/bisync/deltas.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Duplicated code?

@nielash

nielash commented May 11, 2023

Copy link
Copy Markdown
Contributor Author

Thanks so much for the excellent feedback! I'm happy to hear that you're considering this for the next release.

The NewObject thing is something I wondered about too, and wanted to ask your advice about. What would you recommend instead? Also, is there a simpler way of checking whether it's a file or a dir, without relying on ErrorIsDir? (As an aside, I'm presuming that bucket-based backends will not be using --create-empty-src-dirs in the first place, as the feature would be meaningless... but it does concern me that NewObject only returns ErrorIsDir "if possible without doing any extra work"...)

Regarding the tests -- I can do what you're requesting and I don't mind the extra work, but I do fear that the result you're looking for is not truly possible due to the unique way the bisync test suite is designed. I'll explain what I mean below, and if you're ok with this caveat I am happy to do it. (And apologies in advance if this is all stuff you already know -- just making sure we're on the same page.)

The bisync tests compare not only the resulting files but also the debug log to the respective golden versions. (This is why I had to remove *.log from .gitignore, as you noted.) As documented here, this means that just about anything you change will cause false positives, whether or not it's related to what's being tested. For this reason, the recommended workflow is to goldenize, check the difference carefully, and then commit if you're convinced that all the diffs are due either to intentional changes or false positives. (In my opinion, this is kind of a design flaw -- it has the upside of being an extremely sensitive test, but the downside of relying on humans to do the checking, and thus being more prone to human error. It is probably a little too easy, currently, for a future developer to accidentally turn a true positive into a false negative among all the noise.)

As an example, my "equality check" commit adds a line that prints "Files are equal! Skipping." to the log in certain scenarios. Let's assume for simplicity's sake that this is all it does. Every subsequent commit will then expect that line to be there, and fail if it is not. So, let's say that my next commit deals with something totally unrelated, and adds a new test for whatever it is. If you were to then revert the first commit, it would cause tests to fail for the second commit -- even though both commits passed all tests individually, and even though nothing is actually "broken". Removing "Files are equal! Skipping." from all the 'golden' logs might be enough to fix this, but git isn't going to know that, at least for the new test log that didn't exist prior to the second commit. (As another example: even merging the same commits in a different order would likely cause failures.)

So, I can give you a sequence of commits that each pass all their tests, but they will be dependent on their sequence, and therefore not necessarily cherry-pickable. If you were to later revert a commit from the middle of the pack, as you describe, you'd likely have to also revert every commit that came after it (or alternatively push a new commit to re-goldenize.) Does that make sense, and are you ok with that?

Assuming yes, what's your preferred way of receiving these revisions? Should I revert these commits and add new ones, or is it cleanest to just create a new branch?

All of your other comments made total sense and shouldn't be a problem.

Thanks!

@callegar

callegar commented Jun 12, 2023 •

Copy link
Copy Markdown

Wonder if these extended changes might have an effect on #6572 too...

@nielash

nielash commented Jun 14, 2023

Copy link
Copy Markdown
Contributor Author

Wonder if these extended changes might have an effect on #6572 too...

(I replied in the #6572 thread... TL;DR: I think it's fixed in the latest beta, and not specific to bisync.)

Also, @ncw just tagging you here in case you didn't see my previous post with some questions for you (no rush at all.)

@ncw

ncw commented Jun 16, 2023

Copy link
Copy Markdown
Member

Sorry have been rather busy!

Will answer questions inline.

Thanks so much for the excellent feedback! I'm happy to hear that you're considering this for the next release.

I think we might have to push until next release - sorry!

The NewObject thing is something I wondered about too, and wanted to ask your advice about. What would you recommend instead? Also, is there a simpler way of checking whether it's a file or a dir, without relying on ErrorIsDir? (As an aside, I'm presuming that bucket-based backends will not be using --create-empty-src-dirs in the first place, as the feature would be meaningless... but it does concern me that NewObject only returns ErrorIsDir "if possible without doing any extra work"...)

Ideally you'd keep a the objects from the directory listing so you don't have to re-instantate them. This may not be possible of course, but in general NewObject should be avoided in favour of saving objects from listings. For most backends 1 NewObject takes about the same amount of time as 1 directory listing, and on some it takes longer (eg box).

Regarding the tests -- I can do what you're requesting and I don't mind the extra work, but I do fear that the result you're looking for is not truly possible due to the unique way the bisync test suite is designed. I'll explain what I mean below, and if you're ok with this caveat I am happy to do it. (And apologies in advance if this is all stuff you already know -- just making sure we're on the same page.)

The bisync tests compare not only the resulting files but also the debug log to the respective golden versions. (This is why I had to remove *.log from .gitignore, as you noted.) As documented here, this means that just about anything you change will cause false positives, whether or not it's related to what's being tested. For this reason, the recommended workflow is to goldenize, check the difference carefully, and then commit if you're convinced that all the diffs are due either to intentional changes or false positives. (In my opinion, this is kind of a design flaw -- it has the upside of being an extremely sensitive test, but the downside of relying on humans to do the checking, and thus being more prone to human error. It is probably a little too easy, currently, for a future developer to accidentally turn a true positive into a false negative among all the noise.)

These are really what I'd call regression tests then...

As an example, my "equality check" commit adds a line that prints "Files are equal! Skipping." to the log in certain scenarios. Let's assume for simplicity's sake that this is all it does. Every subsequent commit will then expect that line to be there, and fail if it is not. So, let's say that my next commit deals with something totally unrelated, and adds a new test for whatever it is. If you were to then revert the first commit, it would cause tests to fail for the second commit -- even though both commits passed all tests individually, and even though nothing is actually "broken". Removing "Files are equal! Skipping." from all the 'golden' logs might be enough to fix this, but git isn't going to know that, at least for the new test log that didn't exist prior to the second commit. (As another example: even merging the same commits in a different order would likely cause failures.)

So, I can give you a sequence of commits that each pass all their tests, but they will be dependent on their sequence, and therefore not necessarily cherry-pickable. If you were to later revert a commit from the middle of the pack, as you describe, you'd likely have to also revert every commit that came after it (or alternatively push a new commit to re-goldenize.) Does that make sense, and are you ok with that?

Yes that makes sense. I think the intellectual exercise of checking the diffs match what we expect after each change is probably worth doing. We can hopefully spot any problems with that commit.

Noted that it effectively makes the commits un cherry-pickable.

Assuming yes, what's your preferred way of receiving these revisions? Should I revert these commits and add new ones, or is it cleanest to just create a new branch?

I'm happy for you to force push this branch with new commits. That is what I'd normally do. But it doesn't matter much to me so if you want to create a new branch which probably means a new PR that is fine. What I'd probably do is clone the branch as bisync-fixes-and-features-old to make a backup. Then I'd use revert all the code and use git add -p to add the parts of each bit, git stash then make the golden tests, check the diff then add to the commit. Then use git stash pop to get the remaining changes back and repeat for each feature. Then when done, force push here.

All of your other comments made total sense and shouldn't be a problem.

:-)

@ncw ncw modified the milestones: v1.63, v1.64 Jul 1, 2023
@nielash

nielash commented Jul 2, 2023

Copy link
Copy Markdown
Contributor Author

Very helpful, thank you! I think I've found a good solution that eliminates the need to use NewObject. It will take me some time to do all the testing, but I'll get it to you as soon as I can. Thanks!

@nielash
nielash force-pushed the bisync-fixes-and-features branch 3 times, most recently from 02b3922 to 557dc46 Compare July 12, 2023 09:47
@nielash

nielash commented Jul 12, 2023

Copy link
Copy Markdown
Contributor Author

@ncw Ok, I think this is ready for you to take a look, whenever you have a chance. I think it addresses all of your comments. Each commit should now include all relevant documentation and testing changes, and each commit should compile and pass all tests.

The equality check and --create-empty-src-dirs commits are significantly revised to be much more efficient and avoid having to use NewObject. Which of the objects are dirs is now noted during the initial directory listing so we don't have to re-list for each object later. The equality check is now performed once, outside the loop, using the same underlying function as check (so it should be just as efficient.) We do the check only if we need to, and filter it for only the few files we're interested in.

Since this branch has gotten quite noisy with all the reversions, I also made a new "clean" branch with just the "real" commits cherry-picked. Feel free to use whichever you prefer.

Thanks!

@nielash

nielash commented Aug 6, 2023

Copy link
Copy Markdown
Contributor Author

(I added a fix for a small bug I found after a few weeks of real-world use.)

@ncw

ncw commented Aug 9, 2023

Copy link
Copy Markdown
Member

Thanks @nielash for your hard work :-)

Can you rebase this on master and fix the conflict, please. (Its probably the fact I added a new parameter to the flags, you can just use "" for the flag group).

If you can force push your clean branch over this one (with your new fix integrated into the correct commit + the rebase) - that would be my preferred way of working.

I'd like to merge this for v1.64 🤞

nielash added 7 commits August 9, 2023 13:29
.DS_Store is an irrelevant file created automatically by macOS.

*.log can't be ignored because bisync uses .log files in its test suite.
@nielash
nielash force-pushed the bisync-fixes-and-features branch from c00356b to 3ad1ef8 Compare August 9, 2023 17:56
@nielash

nielash commented Aug 9, 2023

Copy link
Copy Markdown
Contributor Author

I think it should be all set now 👍

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @nielash that is a very nice set of patches :-)

I will merge them now.

Any chance you'd like to be the maintainer of rclone's bisync code from now on? Drop me an email to [email protected] if you are interested :-)

@ncw
ncw merged commit 9b3b1c7 into rclone:master Aug 12, 2023
@nielash

nielash commented Aug 12, 2023

Copy link
Copy Markdown
Contributor Author

Thank you @nielash that is a very nice set of patches :-)

Thanks! They've certainly improved my workflow and I hope others will find them helpful as well.

Any chance you'd like to be the maintainer of rclone's bisync code from now on? Drop me an email to [email protected] if you are interested :-)

I'm definitely interested, depending on the time commitment you're looking for. I'll drop you an email 😃

@nielash nielash mentioned this pull request Aug 25, 2023
5 tasks done
nielash added a commit to nielash/rclone that referenced this pull request Sep 5, 2023
Added rc support for the flags recently introduced in rclone#6971.

createEmptySrcDirs
ignoreListingChecksum
resilient
ncw pushed a commit that referenced this pull request Sep 5, 2023
Added rc support for the flags recently introduced in #6971.

createEmptySrcDirs
ignoreListingChecksum
resilient
@nielash nielash added the bisync label Sep 5, 2023
lafkpages pushed a commit to lafkpages/rclone that referenced this pull request Jul 20, 2026
Added rc support for the flags recently introduced in rclone#6971.

createEmptySrcDirs
ignoreListingChecksum
resilient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bisync flag "--create-empty-src-dirs" missing

3 participants