LinkCreatesNamedFile test failure
- Dominant language
- C++
- Stars
- 28.9k
- Forks
- 5.6k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 437
Description
This test is consistently failing in my environment: https://github.com/envoyproxy/envoy/blob/35bf11a0f14a996d4e95b5302b0a953e0beba9f6/test/extensions/common/async_files/async_file_handle_thread_pool_test.cc#L140
Here's my attempt to explain why:
The function `manager_->createAnonymousFile()` relies on the underlying filesystem supporting the `O_TMPFILE` flag: https://github.com/envoyproxy/envoy/blob/35bf11a0f14a996d4e95b5302b0a953e0beba9f6/source/extensions/common/async_files/async_file_manager_thread_pool.cc#L135
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()`: https://github.com/envoyproxy/envoy/blob/35bf11a0f14a996d4e95b5302b0a953e0beba9f6/source/extensions/common/async_files/async_file_context_thread_pool.cc#L49
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
Contributor guide
Assessment
This issue has not been assessed yet.