Repository navigation
Conversation
In DGRAM mode the plugin wraps the server socket in a connection and passes it to unix_socket_conn_add(), which registered the socket in the engine event loop. The collector set with flb_input_set_collector_socket() registers the same socket when it starts, epoll_ctl() fails with EEXIST and the input never reads a datagram: [error] [input collector] COLLECT_EVENT registration failed [error] [input] error starting collector #0: unix_socket.0 [error] could not start collectors for plugin 'unix_socket.0' The DGRAM path already reads through the collector event (ctx->collector_event), so the wrapping connection needs no event of its own. Only STREAM connections are registered now. Signed-off-by: Noam Shlomi <noam.shlomi@audiocodes.com>
In DGRAM mode the dummy connection wraps the server socket, and releasing it closes the socket. The exit callback released the connections first and removed the collector afterwards. With the collector running (previous commit), mk_event_del() then ran on a closed descriptor and every shutdown logged: [ warn] [input] cannot disable event for unix_socket.0 The collector is now removed before the connections are released, as in_tcp and in_syslog do before they destroy their downstream. Signed-off-by: Noam Shlomi <noam.shlomi@audiocodes.com>
Each test sends one JSON map to the socket and waits for the record at the lib output. The DGRAM test fails without the previous commit, since the collector never starts. The tests are built when the plugin is enabled (FLB_IN_UNIX_SOCKET). Signed-off-by: Noam Shlomi <noam.shlomi@audiocodes.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
in_unix_socketwithsocket_mode DGRAMreads nothing: the input fails to start its collector at startup.In DGRAM mode the plugin wraps the server socket in a dummy connection and passes it to
unix_socket_conn_add(), which registered that socket in the engine event loop. The collector created byflb_input_set_collector_socket()registers the same socket when it starts, soepoll_ctl(ADD)fails withEEXIST. The DGRAM read path already uses the collector event (ctx->collector_event), so the dummy connection does not need an event of its own. This now matchesin_udp, whoseudp_conn_add()does not register the connection either.Changes:
in_unix_socket: register only stream connections in the event loop: the fix.in_unix_socket: remove the collector before releasing connections: once the collector runs, shutdown released the dummy connection first. That closes the server socket, so the collector removal then calledmk_event_del()on a closed descriptor and logged[ warn] [input] cannot disable event for unix_socket.0. The collector is now removed first, the orderin_tcpandin_syslogalready use.tests: runtime: in_unix_socket: add DGRAM and STREAM input tests: a new runtime test,flb-rt-in_unix_socket. It is built whenFLB_IN_UNIX_SOCKETis on. On master the DGRAM case fails and the STREAM case passes.STREAM mode does not change. There are no config or output format changes.
Fixes #8943
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-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Please include this fix in the 5.2.x series.
masteris the 5.2 line at the moment (5.2.1), so a merge here reaches 5.2.1; if a5.2branch is cut before this is merged, I will open the backport PR against it.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.
Testing details
Built on Debian trixie (gcc 14) with
-DFLB_TESTS_RUNTIME=On -DFLB_TESTS_INTERNAL=On -DFLB_IN_UNIX_SOCKET=On.Configuration:
Three datagrams were sent with
socket.sendto(b'{"message": "verify N"}', "/tmp/verify-dgram.sock").Before (master 4aa8721): the collector fails, as shown above, and the client gets
ConnectionRefusedError. No records arrive.After:
The metrics reported
unix_socket.0records 3 andstdout.0proc_records 3. The log had no errors or other warnings, and the exit status was 0.Tests:
Valgrind:
Integration,
unix_socket_decode_statusscenario (runs the real binary; it delivers records throughin_unix_socketin STREAM mode and checks DGRAM only for a refused start on a socket that another process holds, so the DGRAM data path is covered by the runtime test above):The same scenario under Valgrind:
Summary by CodeRabbit