tail overhaul (--follow=name, etc.)#2695
Merged
sylvestre merged 68 commits intouutils:mainfrom Jun 7, 2022
Merged
Conversation
* treat input filenames as PathBuf instead of String
This implements `--follow=name` for create/move/delete events. Under the hood crate `notify` provides a cross-platform notification library.
* add stub for `--max-unchanged-stats`
On macOS only `kqueue` is suitable for our use case because `FSEvents` waits until file close to delivers modify events.
32e12a7 to
ccd8890
Compare
* Change data structure from Vec to HashMap in order to better keep track of files while watching them with `--follow=name`. E.g. file paths that were removed while watching them and exit if no files are remaining, etc. * Move all logic related to file handling into a FileHandling trait * Simplify handling of the verbose flag.
This makes uu_tail pass the "gnu/tests/tail-2/descriptor-vs-rename" test. * add tests for descriptor-vs-rename (with/without verbose) * fix some minor error messages
* fix test_retry7 * fix test_follow_descriptor_vs_rename2 * set permissions with set_permissions instead of a call to chmod * improve documentation
* add fixes to pass:
- tail-2/F-vs-rename.sh
- tail-2/follow-name.sh
- tail-2/inotify-hash-abuse.sh
- tail-2/inotify-only-regular.sh
- tail-2/retry.sh
* add/improve documentation
80b70da to
b71b0da
Compare
Contributor
|
The coverage job on linux fails with: |
* add clippy fixes * add cicd fixes
Collaborator
tertsdiepraam
left a comment
There was a problem hiding this comment.
This is excellent! Bravo for sticking with this, the complexity of this feature is wild. I have left some comments for further cleanup, but it looks very good.
Contributor
|
And the CI is now green, bravo :) |
sylvestre
reviewed
Jun 5, 2022
sylvestre
reviewed
Jun 5, 2022
* minor code clean-up * remove test-suite summary from README
Contributor
Author
|
@tertsdiepraam and @sylvestre thank you very much for your review and comments. I addressed all your concerns. |
tertsdiepraam
approved these changes
Jun 6, 2022
Collaborator
tertsdiepraam
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks for addressing those comments and, again, this is a great PR!
Contributor
|
I see an intermittent here: |
Merged
This file contains hidden or 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
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.
I finally consider this ready for review!
TLDR:
--follow=name,--retry,-F,---disable-inotifyLong version:
-Fi.e.--follow=name --retrywith backend support from: inotify (Linux), kqueue (macOS/BSD) and ReadDirectoryChanges (Windows)Note: this uses a release candidate of the notify crate v5 because v4 is very old and doesn't have all the required features.
inotify.max_user_instanceslimit is reached), it can be forced with--use-polling$ tail -f < file,$ tail < DIR,$ tail -F - < file, etc.-[nc]0without-f, exit without readingEnsure that:
--follow=namedoes not imply--retry--follow={descriptor,name}(without--retry) does not wait for the files to appear--retrywithout--followresults in a warningtail --retry --follow={name,descriptor}waits for the file to appeartail --follow=descriptor --retryexits when the file appears untailable--follow=descriptor(without--retry) does not try to open a file after an initial fail, even when there are other tailable filestail -Fretries when the file is initially untailabletail -fworks when renaming the tailed files--verbosetail --follow=namehandles remove, move, truncation, rename, create events correctlySummary
Ensure that the following GNU test-suite tests pass:
Note: 6 of these do not show up in the CI as passes because
append-onlyneeds root privileges, and the other 5 tests marked with#pass on my local machine only. I have no clue why and it's incredible cumbersome to debug the CI so I will refrain from that.Note: there are further details in
tail/README.mdEdit:
Now the
overlay-headers.shtest passes in the CI, although the tests rerun without changes. I suspect scheduling/load on the test VM is the reason.