Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fluent bit config-reload via HTTP #1286

Merged
merged 1 commit into from
Aug 12, 2024
Merged

feat: add fluent bit config-reload via HTTP #1286

merged 1 commit into from
Aug 12, 2024

Conversation

jiuxia211
Copy link
Contributor

@jiuxia211 jiuxia211 commented Aug 6, 2024

What this PR does / why we need it:

Hot reloading can be kicked via HTTP endpoints that are:

PUT /api/v2/reload

POST /api/v2/reload

Which issue(s) this PR fixes:

Fixes #

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


@@ -118,6 +118,8 @@ type Service struct {
EmitterName string `json:"emitterName,omitempty"`
EmitterMemBufLimit string `json:"emitterMemBufLimit,omitempty"`
EmitterStorageType string `json:"emitterStorageType,omitempty"`
// If true enable reloading via HTTP
HotReload *bool `json:"hotReload,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

How to utilize this flag if enabled?
In which version it's added to fluentbit?
@wanjunlei pls take a look

Copy link
Contributor Author

@jiuxia211 jiuxia211 Aug 8, 2024

Choose a reason for hiding this comment

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

On how to use this flag can see https://docs.fluentbit.io/manual/administration/hot-reload
The version added to fluentbit should be v2.1 https://fluentbit.io/announcements/v2.1.0/

Copy link
Member

@benjaminhuo benjaminhuo Aug 9, 2024

Choose a reason for hiding this comment

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

We've already add --enable-hot-reload flag in fluentbit watcher:
https://github.com/fluent/fluent-operator/blob/master/cmd/fluent-watcher/fluentbit/main.go#L76C20-L76C39

And the config will be reload whenever there is a config change by sending SIGHUP signal:
https://github.com/fluent/fluent-operator/blob/master/cmd/fluent-watcher/fluentbit/main.go#L126

FluentBit doc says Fluent Bit supports the hot reloading feature when enabled via the configuration file or command line with -Y or --enable-hot-reload option. which means it's not necessary to add it to configfiles because the command line arg already works.

And fluent operator already supports HTTP settings https://github.com/fluent/fluent-operator/pull/1286/files#diff-7aad9bf9eeeaa93f3a61c5ea93ea5a30d57bcfa6307ec4ea188222fdf69f438cR99-R105

image

@wanjunlei what do you think? do we need to add the hot reload flag to configfiles?

Copy link
Collaborator

Choose a reason for hiding this comment

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

fluentbit already supports hot reload via the --enable-hot-reload flag, so there is no need to add Hot_Reload to theconfig file.

Copy link
Member

@wenchajun wenchajun Aug 9, 2024

Choose a reason for hiding this comment

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

There are several main reasons for adding this parameter:

  1. The reason for debugging. Because fluent-operator wraps the watcher layer, you can only restart the process by restarting the container or changing the configuration of the CR when debugging, restarting the container will be more troublesome and changing the configuration is not easy to locate the problem, so we need a way to send a signal to restart manually for hot loading.
  2. This parameter is one of the officially recommended ways to use this can also be harmonized with the official.
  3. Historical legacy issues, before the signal for hot loading in the watcher layer has been changed, due to the fluentbit version upgrade, so the signal to trigger hot loading has also been changed, and the way through the http is compatible with the lower version, but also for the sake of unity.
  4. Compared to the practice of adding parameters in the watcher layer, I think it is also a simple way to configure directly in the configuration file.
  5. Some users have suggested using multiple hot-loading methods before, so I think this is needed for some users, and this addition does not affect the original architecture.

Copy link
Member

Choose a reason for hiding this comment

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

You have nicely explained this!

@benjaminhuo benjaminhuo merged commit 9b2912f into fluent:master Aug 12, 2024
9 of 10 checks passed
@benjaminhuo
Copy link
Member

I think we're ready to release v3.1.0, are you able to trigger a new release? @wenchajun

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.

4 participants