Skip to content

engine: fail startup when HTTP server cannot start - #12176

Merged
edsiper merged 2 commits into
masterfrom
http-server-bind-12167
Jul 30, 2026
Merged

engine: fail startup when HTTP server cannot start#12176
edsiper merged 2 commits into
masterfrom
http-server-bind-12167

Conversation

@edsiper

@edsiper edsiper commented Jul 30, 2026

Copy link
Copy Markdown
Member

Problem

When the built-in HTTP server is enabled but cannot bind its configured address or port, Fluent Bit logs the listener error and continues running without its health and metrics endpoints.

Fixes #12167.

Root cause

flb_engine_start() created and started the HTTP server without checking either operation's return value. A listener bind failure was therefore discarded and the engine still announced successful startup.

Changes

  • Fail engine startup if the built-in HTTP server cannot be initialized.
  • Fail engine startup if the HTTP server cannot start, including bind failures.
  • Add Python integration coverage that occupies the monitoring port and verifies that Fluent Bit exits with a non-zero status.

User impact

Configurations that explicitly enable the built-in HTTP server will no longer run in a partially initialized state when that server is unavailable. A bind failure now causes a non-zero process exit so supervisors and container runtimes can detect the startup failure.

Validation

  • tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/internal_http_server/tests/test_internal_http_server_001.py -q — 4 passed
  • VALGRIND=1 VALGRIND_STRICT=1 tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/internal_http_server/tests/test_internal_http_server_001.py -q — 4 passed, strict valgrind clean
  • ctest --test-dir build -R '^flb-it-http_server$' --output-on-failure — passed
  • Full PR commit-prefix validation against master — passed

Summary by CodeRabbit

  • Bug Fixes

    • Improved startup error handling for the internal HTTP server.
    • Fluent Bit now reports a clear startup failure when the monitoring port is unavailable or the HTTP server cannot start.
  • Tests

    • Added coverage for port conflicts during internal HTTP server startup.

edsiper added 2 commits July 30, 2026 10:16
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2783a17a-a32f-4ae1-9ea8-c626efa0b001

📥 Commits

Reviewing files that changed from the base of the PR and between dad5356 and a3b358e.

📒 Files selected for processing (2)
  • src/flb_engine.c
  • tests/integration/scenarios/internal_http_server/tests/test_internal_http_server_001.py

📝 Walkthrough

Walkthrough

Fluent Bit now fails startup when the internal HTTP server cannot be created or started. An integration test occupies the monitoring port and verifies startup raises an error and exits non-zero.

Changes

HTTP startup failure handling

Layer / File(s) Summary
Fail startup on HTTP server errors
src/flb_engine.c
flb_engine_start() checks HTTP server creation and startup results, logging errors and returning -1 on failure.
Validate bind failure startup behavior
tests/integration/scenarios/internal_http_server/tests/test_internal_http_server_001.py
The test occupies the monitoring port, asserts FluentBitStartupError, verifies a non-zero process exit, and cleans up resources.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: cosmo0920

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch http-server-bind-12167

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.

@edsiper
edsiper marked this pull request as ready for review July 30, 2026 21:33
@edsiper
edsiper requested a review from cosmo0920 as a code owner July 30, 2026 21:33
@edsiper
edsiper merged commit ee4d1ff into master Jul 30, 2026
62 of 63 checks passed
@edsiper
edsiper deleted the http-server-bind-12167 branch July 30, 2026 21:34

@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: a3b358e236

ℹ️ 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_engine.c
config->http_ctx = flb_hs_create(config->http_listen, config->http_port,
config);
flb_hs_start(config->http_ctx);
if (!config->http_ctx) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required DCO sign-off

The reviewed commit message has no Signed-off-by trailer, so it does not satisfy this repository's mandatory DCO policy and may be rejected during contribution checks; recreate the commit with an appropriate sign-off before submission.

AGENTS.md reference: AGENTS.md:L140-L140

Useful? React with 👍 / 👎.

service.stop()


def test_internal_http_server_bind_failure_fails_startup(monkeypatch):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the integration coverage into a separate commit

This commit combines the engine implementation in src/flb_engine.c with Python integration-suite changes, although repository branch practice requires core plumbing and integration tests to be committed separately; split the implementation and regression coverage into component-scoped commits before submission.

AGENTS.md reference: AGENTS.md:L167-L172

Useful? React with 👍 / 👎.

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.

HTTP server bind failure does not fail startup

1 participant