Skip to content

[backport 5.2] out_file: create parent directories with a loop - #12913

Merged
edsiper merged 2 commits into
5.2from
backport-5.2-out_file-mkpath
Dec 3, 2026
Merged

edsiper merged 2 commits into
5.2from
backport-5.2-out_file-mkpath

Conversation

@edsiper

@edsiper edsiper commented Dec 3, 2026

Copy link
Copy Markdown
Member

Backport of #12909 to 5.2. Both commits cherry-pick cleanly with no
changes.

Scope

  • plugins/out_file/file.c: mkpath() is now a single implementation that
    works in a loop over a private copy of the path: it walks back to the
    deepest directory that exists and then creates one level at a time. Two
    small helpers hold the platform differences (path separator and the
    create call).
  • tests/runtime/out_file.c: new mkdir_nested case covering several
    missing levels below an existing parent, with a trailing separator in
    the configured path.

No configuration options change.

Compatibility notes

  • A directory created by another writer between the check and the create
    call is now accepted instead of reported as an error.
  • A trailing separator in the directory path is no longer treated as an
    additional level.
  • Windows: the drive prefix is skipped as before, and both \ and / are
    accepted as separators. This platform was not exercised locally; CI
    covers it.

Testing

Linux x86_64, built from this branch:

  • ctest --test-dir build -R flb-rt-out_file --output-on-failure
    • 2/2 passed (flb-rt-out_file, flb-rt-out_file_rotation)
  • valgrind --leak-check=full ./build/bin/flb-rt-out_file mkdir mkdir_nested
    • passed, no errors
  • python -m pytest tests/integration/scenarios/out_file -q
    • 24 passed
  • VALGRIND=1 VALGRIND_STRICT=1 python -m pytest tests/integration/scenarios/out_file -q
    • 24 passed
  • Manual run of the built binary with in_http and out_file using
    Mkdir On: records written, clean shutdown.
  • commit_prefix_check.py over the PR range: passed

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Rework mkpath() to walk the path in a loop over a private copy: find
the deepest existing parent, then create one level at a time. The
three per-platform variants become a single implementation with
small helpers for the separator and the create call.

A directory created by another writer in the meantime is now
accepted, and a trailing separator no longer counts as a level.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
(cherry picked from commit d1b4d0c)
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Check that out_file creates several missing directory levels below
an existing parent when the configured path ends with a separator.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
(cherry picked from commit 2a29b50)
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@edsiper
edsiper requested a review from cosmo0920 as a code owner December 3, 2026 13:22
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2c5d7d8-4a01-4582-a16a-ea884a43e0a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T13:23:50.738703Z 325acf3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@edsiper edsiper added this to the Fluent Bit v5.2.2 milestone Dec 3, 2026
@edsiper
edsiper merged commit 2b057c0 into 5.2 Dec 3, 2026
58 of 60 checks passed
@edsiper
edsiper deleted the backport-5.2-out_file-mkpath branch December 3, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant