Repository navigation
fix(fileutils): fail createFifo when an existing path is not a FIFO - #301
Merged
Merged
Conversation
Contributor
Author
|
/test |
YanniHu1996
approved these changes
Jul 20, 2026
GabriFedi97
reviewed
Jul 21, 2026
litaocdl
force-pushed
the
dev/298
branch
2 times, most recently
from
July 22, 2026 07:15
b645835 to
18b432e
Compare
GabriFedi97
approved these changes
Jul 23, 2026
armru
approved these changes
Jul 23, 2026
Signed-off-by: Tao Li <[email protected]>
Signed-off-by: Tao Li <[email protected]> Signed-off-by: Gabriele Fedi <[email protected]> Co-authored-by: Gabriele Fedi <[email protected]> Signed-off-by: Tao Li <[email protected]>
Moving from os.Stat to os.Lstat is the one behavioral change this fix makes against the old implementation: a symlink at the path is no longer followed, so even a symlink that targets a genuine FIFO is reported as an error rather than silently accepted. Pin that intent with a spec so a later switch back to a link-following stat is caught. Signed-off-by: Armando Ruocco <[email protected]>
CreateFifo used Lstat to check whether an existing path is already a FIFO, but the readers that open this path (os.OpenFile, with no O_NOFOLLOW) follow symlinks. A symlink pointing at a genuine, usable FIFO was therefore rejected as ErrExistsNotFifo even though the reader would have opened and streamed from it correctly. Switch the check to Stat so it resolves the path the same way the reader does: a symlink to a FIFO is accepted, while a symlink to a regular file (or any other non-FIFO) is still rejected, preserving the original fix for a stale file left where a FIFO is expected. Signed-off-by: Armando Ruocco <[email protected]>
GabriFedi97
approved these changes
Jul 23, 2026
mnencia
added a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 29, 2026
…11246) `wal-archive` and `wal-restore` run as separate `/controller/manager` processes and are told to write their logs to `--log-destination <LogPath>/postgres.json`, the same path the instance manager's JSON log pipe uses for its FIFO. If one of those commands opens the destination before the pipe has created the FIFO, `customDestination` creates a plain regular file there (it opens with `O_CREATE`). The pipe then finds a non-FIFO at the path; until now it silently accepted it, so the reader opened a static file, reached EOF, and no `wal-archive`/`wal-restore` output was ever captured. That is the silence reported in #11201. Now that `CreateFifo` reports `ErrExistsNotFifo` for a non-FIFO, the pipe reacts to it: it removes the stale entry and lets the next iteration create the FIFO, so streaming recovers without operator action. The path lives on an `emptyDir` that outlives container restarts, so without this the only recovery is recreating the pod. The removal is deliberately narrow: it fires only on `ErrExistsNotFifo`, logs a warning first, and drops just the name at the path (a symlink is removed, never its target). An in-flight writer holding the old inode loses its buffered lines, but the next invocation opens the fresh FIFO; that is convergent and acceptable for a transient log-staging path. The retry loops also gain a short, cancellable backoff so a persistent failure no longer busy-spins. The machinery dependency is pinned (operator and e2e modules) to machinery's `main` tip, which carries the `ErrExistsNotFifo` fix (cloudnative-pg/machinery#301, merged) ahead of a tagged release; re-pin to a tagged release once machinery cuts one. Closes #11201 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Tao Li <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Tao Li <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]>
cnpg-bot
pushed a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 29, 2026
…11246) `wal-archive` and `wal-restore` run as separate `/controller/manager` processes and are told to write their logs to `--log-destination <LogPath>/postgres.json`, the same path the instance manager's JSON log pipe uses for its FIFO. If one of those commands opens the destination before the pipe has created the FIFO, `customDestination` creates a plain regular file there (it opens with `O_CREATE`). The pipe then finds a non-FIFO at the path; until now it silently accepted it, so the reader opened a static file, reached EOF, and no `wal-archive`/`wal-restore` output was ever captured. That is the silence reported in #11201. Now that `CreateFifo` reports `ErrExistsNotFifo` for a non-FIFO, the pipe reacts to it: it removes the stale entry and lets the next iteration create the FIFO, so streaming recovers without operator action. The path lives on an `emptyDir` that outlives container restarts, so without this the only recovery is recreating the pod. The removal is deliberately narrow: it fires only on `ErrExistsNotFifo`, logs a warning first, and drops just the name at the path (a symlink is removed, never its target). An in-flight writer holding the old inode loses its buffered lines, but the next invocation opens the fresh FIFO; that is convergent and acceptable for a transient log-staging path. The retry loops also gain a short, cancellable backoff so a persistent failure no longer busy-spins. The machinery dependency is pinned (operator and e2e modules) to machinery's `main` tip, which carries the `ErrExistsNotFifo` fix (cloudnative-pg/machinery#301, merged) ahead of a tagged release; re-pin to a tagged release once machinery cuts one. Closes #11201 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Tao Li <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Tao Li <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit aa196ca)
cnpg-bot
pushed a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 29, 2026
…11246) `wal-archive` and `wal-restore` run as separate `/controller/manager` processes and are told to write their logs to `--log-destination <LogPath>/postgres.json`, the same path the instance manager's JSON log pipe uses for its FIFO. If one of those commands opens the destination before the pipe has created the FIFO, `customDestination` creates a plain regular file there (it opens with `O_CREATE`). The pipe then finds a non-FIFO at the path; until now it silently accepted it, so the reader opened a static file, reached EOF, and no `wal-archive`/`wal-restore` output was ever captured. That is the silence reported in #11201. Now that `CreateFifo` reports `ErrExistsNotFifo` for a non-FIFO, the pipe reacts to it: it removes the stale entry and lets the next iteration create the FIFO, so streaming recovers without operator action. The path lives on an `emptyDir` that outlives container restarts, so without this the only recovery is recreating the pod. The removal is deliberately narrow: it fires only on `ErrExistsNotFifo`, logs a warning first, and drops just the name at the path (a symlink is removed, never its target). An in-flight writer holding the old inode loses its buffered lines, but the next invocation opens the fresh FIFO; that is convergent and acceptable for a transient log-staging path. The retry loops also gain a short, cancellable backoff so a persistent failure no longer busy-spins. The machinery dependency is pinned (operator and e2e modules) to machinery's `main` tip, which carries the `ErrExistsNotFifo` fix (cloudnative-pg/machinery#301, merged) ahead of a tagged release; re-pin to a tagged release once machinery cuts one. Closes #11201 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Tao Li <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Tao Li <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit aa196ca)
mnencia
added a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 29, 2026
…11246) `wal-archive` and `wal-restore` run as separate `/controller/manager` processes and are told to write their logs to `--log-destination <LogPath>/postgres.json`, the same path the instance manager's JSON log pipe uses for its FIFO. If one of those commands opens the destination before the pipe has created the FIFO, `customDestination` creates a plain regular file there (it opens with `O_CREATE`). The pipe then finds a non-FIFO at the path; until now it silently accepted it, so the reader opened a static file, reached EOF, and no `wal-archive`/`wal-restore` output was ever captured. That is the silence reported in #11201. Now that `CreateFifo` reports `ErrExistsNotFifo` for a non-FIFO, the pipe reacts to it: it removes the stale entry and lets the next iteration create the FIFO, so streaming recovers without operator action. The path lives on an `emptyDir` that outlives container restarts, so without this the only recovery is recreating the pod. The removal is deliberately narrow: it fires only on `ErrExistsNotFifo`, logs a warning first, and drops just the name at the path (a symlink is removed, never its target). An in-flight writer holding the old inode loses its buffered lines, but the next invocation opens the fresh FIFO; that is convergent and acceptable for a transient log-staging path. The retry loops also gain a short, cancellable backoff so a persistent failure no longer busy-spins. The machinery dependency is pinned (operator and e2e modules) to machinery's `main` tip, which carries the `ErrExistsNotFifo` fix (cloudnative-pg/machinery#301, merged) ahead of a tagged release; re-pin to a tagged release once machinery cuts one. Closes #11201 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Tao Li <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Tao Li <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit aa196ca)
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.
Update the CreateFifo check logical: no-ops only if it's already a FIFO;
create the FIFO only if file not exists; fail the call if non-FIFO file exists and for other
errors.
Closes: #298