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

LinkCreatesNamedFile test failure #23821

Open
jwendell opened this issue Nov 3, 2022 · 9 comments
Open

LinkCreatesNamedFile test failure #23821

jwendell opened this issue Nov 3, 2022 · 9 comments
Assignees
Labels
area/test flakes bug no stalebot Disables stalebot from closing an issue

Comments

@jwendell
Copy link
Member

jwendell commented Nov 3, 2022

This test is consistently failing in my environment:

TEST_F(AsyncFileHandleTest, LinkCreatesNamedFile) {

Here's my attempt to explain why:

The function manager_->createAnonymousFile() relies on the underlying filesystem supporting the O_TMPFILE flag:

open_result = posix().open(path_.c_str(), O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);

The fallback code (a few lines below) creates a file and deletes it, without closing it, returning its file descriptor. I'm reaching this fallback code, because my filesystem doesn't support the O_TMPFILE flag.

The problem happens when a hard link is created later with linkat():

auto result = posix().linkat(fileDescriptor(), procfile.c_str(), AT_FDCWD, filename_.c_str(),

It fails with ENOENT, as stated in the manual page:

ENOENT An attempt was made to link to a /proc/self/fd/NN file
              corresponding to a file that has been deleted.

As seen here: https://man7.org/linux/man-pages/man2/link.2.html

cc @ravenblackx

@jwendell jwendell added bug triage Issue requires triage labels Nov 3, 2022
@ravenblackx
Copy link
Contributor

ravenblackx commented Nov 4, 2022

What sort of environment is it that exhibits this failure? (Thinking maybe an NTFS filesystem on Linux?)

I would suggest this could be fixed by having the fallback behavior create a named temporary file (unfortunately), keeping track of that file in the AsyncFileContext object, moving it in lieu of linkat or deleting it during close. It should maybe be a distinct AsyncFileContext (though perhaps a subclass of AsyncFileContextThreadPool) since the more common case works without that information. That variant could also potentially make this able to function in Windows.

(Unfortunate because it could potentially make for inconsistent behavior with any code that looks at directory contents, and it will leave a mess behind if a crash occurs while the file exists, like the regular variant does not.)

@jwendell
Copy link
Member Author

jwendell commented Nov 4, 2022

The env is a docker container running in a k8s cluster probably running in an old kernel.

@phlax phlax added area/test flakes and removed triage Issue requires triage labels Nov 7, 2022
@github-actions
Copy link

github-actions bot commented Dec 7, 2022

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 7, 2022
@ravenblackx
Copy link
Contributor

I have a plan to address this, involving migrating AsyncFileManager to using Envoy::Filesystem::File, after making File have an implementation for temp files and all the other required operations.
I'd assign this issue to me but I don't think I have permission to do that.

@github-actions github-actions bot removed the stale stalebot believes this issue/PR has not been touched recently label Dec 7, 2022
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Jan 6, 2023
@ravenblackx
Copy link
Contributor

Still working on it, bot!

@github-actions github-actions bot removed the stale stalebot believes this issue/PR has not been touched recently label Jan 7, 2023
@github-actions
Copy link

github-actions bot commented Feb 6, 2023

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Feb 6, 2023
@ravenblackx
Copy link
Contributor

Still in my queue, not stale!

@github-actions github-actions bot removed the stale stalebot believes this issue/PR has not been touched recently label Feb 6, 2023
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Mar 9, 2023
@ravenblackx ravenblackx self-assigned this Mar 9, 2023
@ravenblackx ravenblackx added no stalebot Disables stalebot from closing an issue and removed stale stalebot believes this issue/PR has not been touched recently labels Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test flakes bug no stalebot Disables stalebot from closing an issue
Projects
None yet
Development

No branches or pull requests

3 participants