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

plugin_proxy: Allow to execute flush callback on Golang side during hot-reloading #9734

Conversation

imankurpatel000
Copy link
Contributor

@imankurpatel000 imankurpatel000 commented Dec 16, 2024

Removes the code which prevented flush callback on Golang side during hot-reloading

Fixes #9733


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • Backport to latest stable release.

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.

@imankurpatel000
Copy link
Contributor Author

Testing

  1. For testing the change, first build a local docker image from this branch of fluent-bit
    docker build . -t fluent-bit-local --platform=linux/arm64
  2. Clone the repo for reproducing the problem.
    git clone https://github.com/imankurpatel000/fluent-bit-hot-reload-issue
  3. Modify this line to use locally built fluent-bit image.
-    image: fluent/fluent-bit:latest
+    image: fluent-bit-local:latest
  1. Follow the steps in Readme and try to replicate the issue again.

Output logs

Since this required a specific setup to work which requires generating a lot of logs, there were lot of debug logs generated so it wasn't easy to show that this change actually fixed the issue. So here are are logs with the default Log_level. But let me know if debug logs are still required.

❯ docker-compose up                                                                     ─╯
[+] Running 2/0
 ✔ Container fluent-bit-hot-reload-issue-fluent-bit-1     Created                     0.0s 
 ✔ Container fluent-bit-hot-reload-issue-log-generator-1  Created                     0.0s 
Attaching to fluent-bit-1, log-generator-1
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] Register called
fluent-bit-1     | Fluent Bit v3.2.3
fluent-bit-1     | * Copyright (C) 2015-2024 The Fluent Bit Authors
fluent-bit-1     | * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
fluent-bit-1     | * https://fluentbit.io
fluent-bit-1     | 
fluent-bit-1     | ______ _                  _    ______ _ _           _____  _____ 
fluent-bit-1     | |  ___| |                | |   | ___ (_) |         |____ |/ __  \
fluent-bit-1     | | |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
fluent-bit-1     | |  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /  
fluent-bit-1     | | |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
fluent-bit-1     | \_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/
fluent-bit-1     | 
fluent-bit-1     | 
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [fluent bit] version=3.2.3, commit=2b279bfea6, pid=1
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [simd    ] disabled
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [cmetrics] version=0.9.9
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [ctraces ] version=0.5.7
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [input:tail:fluent-tail-input] initializing
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [input:tail:fluent-tail-input] storage_strategy='memory' (memory only)
fluent-bit-1     | [2024/12/16 16:40:57] [error] [input:tail:fluent-tail-input] parser 'docker' is not registered
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [sp] stream processor started
fluent-bit-1     | [2024/12/16 16:40:57] [ info] [input:tail:fluent-tail-input] inotify_fs_add(): inode=58 watch_fd=1 name=/var/log/test.log
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:57 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:58 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:58 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:58 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:59 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:59 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:40:59 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:00 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:00 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:00 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:01 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:01 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:01 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:02 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:02 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:02 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:03 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:03 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:03 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:04 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:04 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:04 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:05 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:05 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:05 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | [2024/12/16 16:41:06] [engine] caught signal (SIGHUP)
fluent-bit-1     | [2024/12/16 16:41:06] [ info] reloading instance pid=1 tid=0xffffb66e9020
fluent-bit-1     | [2024/12/16 16:41:06] [ info] [reload] slist externals /etc/out_multiinstance.so
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Register called
fluent-bit-1     | [2024/12/16 16:41:06] [ info] [reload] stop everything of the old context
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:06 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | [2024/12/16 16:41:06] [ warn] [engine] service will shutdown when all remaining tasks are flushed
fluent-bit-1     | [2024/12/16 16:41:06] [ info] [input] pausing fluent-tail-input
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [engine] service has stopped (0 pending tasks)
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [input] pausing fluent-tail-input
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] Exit called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] Exit called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] Exit called for id: dummy_metrics
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [input:tail:fluent-tail-input] inotify_fs_remove(): inode=58 watch_fd=1
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] Unregister called
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [reload] start everything
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [fluent bit] version=3.2.3, commit=2b279bfea6, pid=1
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [simd    ] disabled
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [cmetrics] version=0.9.9
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [ctraces ] version=0.5.7
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [input:tail:fluent-tail-input] initializing
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [input:tail:fluent-tail-input] storage_strategy='memory' (memory only)
fluent-bit-1     | [2024/12/16 16:41:07] [error] [input:tail:fluent-tail-input] parser 'docker' is not registered
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | 2024/12/16 16:41:07 [multiinstance] id = "dummy_metrics"
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [sp] stream processor started
fluent-bit-1     | [2024/12/16 16:41:07] [ info] [input:tail:fluent-tail-input] inotify_fs_add(): inode=58 watch_fd=1 name=/var/log/test.log
fluent-bit-1     | 2024/12/16 16:41:08 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:08 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:08 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:09 [multiinstance] Flush called for id: dummy_metrics
fluent-bit-1     | 2024/12/16 16:41:09 [multiinstance] Flush called for id: dummy_metrics

As you can see after SIGHUP is received, go plugin continues to flush the remaining the chunks and then reload continues to actually reload the fluent-bit.

src/flb_plugin_proxy.c Show resolved Hide resolved
@cosmo0920 cosmo0920 added this to the Fluent Bit v3.2.3 milestone Dec 18, 2024
@niedbalski niedbalski merged commit 44a2d0d into fluent:master Dec 19, 2024
53 checks passed
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.

Pending tasks fails to flush during hot reload when using external go output plugins
3 participants