-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
tail
overhaul (--follow=name, etc.)
#2695
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
The coverage job on linux fails with:
|
* add clippy fixes * add cicd fixes
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.
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.
And the CI is now green, bravo :) |
* minor code clean-up * remove test-suite summary from README
@tertsdiepraam and @sylvestre thank you very much for your review and comments. I addressed all your concerns. |
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.
Looks good to me! Thanks for addressing those comments and, again, this is a great PR!
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.
LGTM, bravo!
I see an intermittent here:
|
I finally consider this ready for review!
TLDR:
--follow=name
,--retry
,-F
,---disable-inotify
Long version:
-F
i.e.--follow=name --retry
with 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_instances
limit is reached), it can be forced with--use-polling
$ tail -f < file
,$ tail < DIR
,$ tail -F - < file
, etc.-[nc]0
without-f
, exit without readingEnsure that:
--follow=name
does not imply--retry
--follow={descriptor,name}
(without--retry
) does not wait for the files to appear--retry
without--follow
results in a warningtail --retry --follow={name,descriptor}
waits for the file to appeartail --follow=descriptor --retry
exits 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 -F
retries when the file is initially untailabletail -f
works when renaming the tailed files--verbose
tail --follow=name
handles 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-only
needs 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.md
Edit:
Now the
overlay-headers.sh
test passes in the CI, although the tests rerun without changes. I suspect scheduling/load on the test VM is the reason.