Skip to content

reload: preserve configuration path during hot reload - #12336

Open
antonio wants to merge 4 commits into
fluent:masterfrom
antonio:antonio/fix-hot-reload-conf-path
Open

reload: preserve configuration path during hot reload#12336
antonio wants to merge 4 commits into
fluent:masterfrom
antonio:antonio/fix-hot-reload-conf-path

Conversation

@antonio

@antonio antonio commented Aug 26, 2026

Copy link
Copy Markdown

Hot reload now preserves the directory of the main configuration when it creates the replacement context.

Fluent Bit uses this path to resolve relative service file references. Startup sets the path correctly, but reload creates a fresh context without carrying it over. As a result, relative Parsers_File and Plugins_File references that work at startup fail during reload.

Copying the path before loading the new configuration allows the existing path resolution to work unchanged. This also adds regression coverage for relative parser paths in both classic and YAML configurations.

Disclosure: I developed this change with AI assistance. I have not written C code in more than 20 years, so I would appreciate particular scrutiny of the memory ownership, cleanup paths, and conformity with Fluent Bit’s conventions.

Fixes #12333

Summary by CodeRabbit

  • Bug Fixes

    • Improved hot-reload reliability for configurations using relative parser files.
    • Preserved the active configuration path during reloads.
    • Added safer cleanup and watchdog handling when reloads cannot be completed.
    • Ensured parser files remain available and load correctly after configuration replacement.
  • Tests

    • Expanded hot-reload coverage for classic and YAML configurations.
    • Added validation of parser loading before and after reloads.
    • Added coverage for halted reload scenarios and configuration path handling.

Relative service file references resolve against the directory containing
the main configuration. Reload created a new context without preserving
that directory, so relative files could no longer be resolved.

Copy the canonical path before loading the new configuration. Parsers,
external plugins, upstream HA files, and stream processor files all use
this path when resolving relative references.

Fixes fluent#12333

Signed-off-by: Antonio Santos <antonio@santosvelasco.com>
Signed-off-by: Antonio Santos <antonio@santosvelasco.com>
Signed-off-by: Antonio Santos <antonio@santosvelasco.com>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f0f70f6f-ef5e-4ac9-8de7-ef4efa905806

📥 Commits

Reviewing files that changed from the base of the PR and between 6a1ed7d and 39aa815.

📒 Files selected for processing (1)
  • tests/internal/reload.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Hot reload now preserves the main configuration directory when creating a new configuration. Integration and internal tests verify relative parser files after startup and HTTP-triggered reloads.

Changes

Hot reload relative path handling

Layer / File(s) Summary
Preserve configuration directory during reload
src/flb_reload.c
The reload path copies conf_path into the new configuration. Allocation failure performs cleanup, stops the watchdog, and returns FLB_RELOAD_HALTED.
Cover relative parser files through HTTP reload
tests/integration/scenarios/hot_reload_watch/config/*, tests/integration/scenarios/hot_reload_watch/tests/test_hot_reload_watch_001.py
The integration test stages a relative parser file beside classic and YAML runtime configurations. It validates initial parsing, disabled automatic reload, HTTP reload, and updated output.
Validate parser preservation in internal reload tests
tests/internal/data/reload/*, tests/internal/reload.c
The internal test loads reload_test, configures conf_path, and verifies parser availability and path preservation after reload. It asserts reload status and reports failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 39aa8

Hot reload now preserves the configuration directory so relative parser and plugin references resolve consistently with startup; the replacement context is independently owned and cleaned up on pre-replacement failures, and no actionable merge-blocking risk remains.

Suggested reviewers: edsiper

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: preserving the configuration path during hot reload.
Linked Issues check ✅ Passed The implementation copies old_config->conf_path into the replacement context. The integration and internal tests cover relative parser files in classic and YAML configurations, which addresses the rel…
Out of Scope Changes check ✅ Passed All changes support issue [#12333]. The source change preserves the configuration directory, and the added tests and configuration files verify relative parser resolution during hot reload.
Full details: Linked Issues check

Explanation

The implementation copies old_config->conf_path into the replacement context. The integration and internal tests cover relative parser files in classic and YAML configurations, which addresses the relative-path resolution failure described in issue [#12333].

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a1ed7d9de

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flb_reload.c

@cosmo0920 cosmo0920 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work.
It's a really good first step to mitigate handling relative paths during hot-reloading.

I found an issue on a testing assertion.
Could you address on it?

Comment thread tests/internal/reload.c Outdated
Signed-off-by: Antonio Santos <antonio@santosvelasco.com>
@cosmo0920 cosmo0920 added this to the Fluent Bit v5.1.2 milestone Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hot reload fails to resolve relative file paths against the main configuration directory

2 participants