-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
plugins: exec: exit fluent-bit after oneshot and propagate exit code #7207
Conversation
Config samples; these all expect a
and
Runs until signalled. Exiting behaviour. fluent-bit-exec-and-exit-conf.txt
Exits once command exits. Even though command exited with nonzero, fluent-bit exits with zero. fluent-bit-exec-and-exit-propagate-conf.txt
Exits when command exits, propagates child process exit code. |
386669f
to
87d2da6
Compare
Updated PR to improve signal handling logic and related comments. Updated the docs PR to better discuss exit codes. I can't see any existing tests for the |
I went to run this with Built on Ubuntu 22.10 with gcc 12.2.0 using default cmake options:
I used the Perl script in https://wiki.wxwidgets.org/Parse_valgrind_suppressions.sh to generate a suppressions file; obviously hand-writing would be better, but it was just too huge. With a number of iterations I ended up with a suppressions file that matched for the simple case I ran, but since some of the suppressions are calls with variable paths into libraries, I found that the tiniest change in invocation led to new and unrelated valgrind errors. Unless there's a current suppressions file somewhere, or some build/runtime options that encourage fluent-bit to run more valgrind-clean, I can't give you any useful valgrind output. All I can really do is attach the suppressions file that matches all the valgrind errors I see reported, which I will include here. Of these suppressions, the only ones that mention the I'll try to attach a full valgrind run log anyway, but the noise is so great I don't expect it'll be much use. |
fluent-bit-exec-and-exit-propagate-debuglog.txt Debug logs with the propagate flag set, run as
|
What're the next steps here? I'm currently working around this with a really ugly hack using the |
Is this project active? Is there anything else I need to do in order to get a PR checked? |
Enabling the exec input plugin is something we planned on doing soon but I noticed the macros to check the process status might not be available yet something easy to overcome. Would you mind taking a look at that? I'd really appreciate it. |
Btw, sorry about the lack of interaction, for some reason I didn't see this PR before. |
Thanks @leonardo-albertovich for taking a look.
I'm not sure what you mean by this. Do you mean the macros Are you asking for a CMake feature test for these macros to be added? I could probably do that if required, though it's kind of implied by building on a posix-alike platform. Is your concern re MS Windows support? I didn't find a lot of info about Windows in the fluent-bit docs, but I took a look at the failing test runs, but there's no sign they're relevant to this change as opposed to being unstable tests:
All failures are on OSX. Looks like issues with OSX tests rather than this PR. So I'm not quite sure what you're asking me to do. |
e2c1609
to
fcc67f3
Compare
What I was saying was that those macros are not present in windows and since the plugin already uses popen we were thinking of enabling it in windows even if that meant making it experimental and adding a big red label. I understand the limitations and caveats that come with windows and a "universal" approach and at some point we might want to abstract the process management and console redirection in platform specific implementations shared by the same plugin but that's not what we had in mind for the moment. So what I'm asking you to do is to make sure this feature doesn't make it harder for us to enable the plugin in windows and the two options are :
|
Hi @ringerc, |
@leonardo-albertovich OK, that makes sense, so it is about windows. I'll take a look. |
@dkmorgan something like
with
and
I'm sure you can see why I bothered with the Note that this approach does nothing special for signal handling. A |
Thanks @ringerc, we appreciate the effort. Please let me know once you make those changes and I'll merge this. |
Test steps for doing this with a canned MSVC VM on Azure:
I found that Fluent Bit's cmake code does not raise a fatal error if openssl cannot be found, but then fails to build if openssl is absent, with errors like Grepping randomly around the repo to try to figure out how fluent-bit is built for Windows I stumbled on
Then re-ran the build
which now fails with I'm guessing this might be due to missing flex and bison, and the fluent-bit build system failing to check for errors? Grabbed Now weirdly, I notice in But
so I'm confused. This is a pain. I can't easily use the ok, installing flex and bison and re-running
worked. Note that you have to unpack the whole winflexbision archive to This build needs some error checking of command exit values and required headers At the very least the cmake run should abort if
|
New separate PR to fix the windows build complaints somewhat #7463 |
Add a compatibility shim to handle win32's lack of POSIX sys/wait.h macros like WIFEXITED, so fluent-bit's in_exec plugin can use them on platforms where they're supported, but fall back to a simple exit code extraction on windows. Signed-off-by: Craig Ringer <[email protected]>
6722861
to
b4cdb89
Compare
@leonardo-albertovich Fixed tabs |
(Don't like that this PR doesn't add test cover, but I'm not writing a whole new test module for a plugin that has none already, especially given that fluent-bit uses its own bespoke test suite with limited docs and examples.) |
The failing tests are
in https://github.com/fluent/fluent-bit/actions/runs/5063344577/jobs/9108776973?pr=7207 which are clearly unrelated to this change, and I've seen be unstable in multiple recent runs. AFAICS this is ready for merge, how to I get it progressed to merge? |
Don't worry about those, we are in the process of fixing them (it's a localized issue in macos). Your PR is fine. |
commits must be prefixed with the plugin name , e.g: |
Thankyou @edsiper You can probably enable the |
@edsiper The docs PR for this change at fluent/fluent-bit-docs#1080 pending merge too |
Docs will be merged once a release is done @ringerc - otherwise it confuses people to see the docs up for something not available in the release. |
Can you submit a PR for this? |
Work done as part of fluent#7207 made the in_exec plugin build-able on Windows, but did not enable it as part of the build. Enable its compliation on Windows.
Work done as part of fluent#7207 made the in_exec plugin build-able on Windows, but did not enable it as part of the build. Enable its compliation on Windows. Signed-off-by: Craig Ringer <[email protected]>
@patrick-stephens #7664 as requested . I've torn down my Windows dev-env (it was an Azure VM) after this work closed out, so I can't easily do any manual testing of it, but the github CI stuff should run to validate the build at least. |
…t#7207) Exit fluent-bit when the child process of the 'exec' plugin exits in one-shot mode if the new Exit_After_Oneshot plugin option is true. While exiting after the oneshot command is the logical behaviour, doing so by default would change existing behaviour that may affect existing uses, so it's not made the default. Optionally propagate the child process exit code to the exit code of fluent-bit itself if the new plugin option Propagate_Oneshot_Exit_Code is True. This allows fluent-bit to be invoked as a wrapper for a child command. Add a compatibility shim to handle win32's lack of POSIX sys/wait.h macros like WIFEXITED, so fluent-bit's in_exec plugin can use them on platforms where they're supported, but fall back to a simple exit code extraction on windows. Signed-off-by: Craig Ringer <[email protected]>
Work done as part of #7207 made the in_exec plugin build-able on Windows, but did not enable it as part of the build. Enable its compliation on Windows. Signed-off-by: Craig Ringer <[email protected]>
Enable use of
fluent-bit
as a log-processing command wrapper by enhancing theexec
plugin with options to exit on child process exit and propagate exit code.Adds new options to
in_exec
plugin:Exit_After_Oneshot
impliesOneshot
and causesfluent-bit
to terminate when the command run by theexec
plugin terminates.Propagate_Exit_Code
causesfluent-bit
to exit with the same exit code as the on-shot child process it invoked, following the shell convention for handling of signal exits.Obviously practical uses will really be parsing and transforming the logs, shipping logs to external capture services, etc.
While exiting when the one-shot command exits would probably be a sensible default, that might surprise any existing users of the current one-shot option so it is not made the default. That way this change remains backwards compatible with existing
oneshot
uses.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:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Docs PR: fluent/fluent-bit-docs#1080
Backporting
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.