Skip to content

engine: context event loop.#10244

Draft
pwhelan wants to merge 15 commits intomasterfrom
pwhelan-event-reload
Draft

engine: context event loop.#10244
pwhelan wants to merge 15 commits intomasterfrom
pwhelan-event-reload

Conversation

@pwhelan
Copy link
Contributor

@pwhelan pwhelan commented Apr 23, 2025

Summary

Add a new event loop for contexts and for signaling context events.

Description

This event loop has a channel that is used internally for signals, ie: shutdown, reload, etc... The main loop now uses this event loop to receive shutdown and reload signals.

This should solve the issue addressed in #9908 in a cross platform and much more stable and clean manner.


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
  • 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.

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

Documentation

  • 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.

pwhelan added 5 commits April 23, 2025 16:53
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
@pwhelan pwhelan marked this pull request as draft April 23, 2025 21:00
@pwhelan pwhelan changed the title Pwhelan event reload engine: event reload Apr 23, 2025
@pwhelan pwhelan changed the title engine: event reload engine: context event loop. Apr 23, 2025
…own and reload.

Signed-off-by: Phillip Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Whelan <phillip.whelan@chronosphere.io>
pwhelan added 5 commits May 9, 2025 12:58
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
…ontext loop.

Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
pwhelan added 2 commits May 9, 2025 14:57
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Signed-off-by: Phillip Adair Stewart Whelan <phillip.whelan@chronosphere.io>
Copy link
Contributor

@leonardo-albertovich leonardo-albertovich left a comment

Choose a reason for hiding this comment

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

I can't conduct a complete review now but please check this out.

static void flb_signal_handler_break_loop(int signal)
{
exit_signal = signal;
flb_config_signal_send(config, FLB_CTX_SIGNAL_SHUTDOWN);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't call flb_pipe_w from a signal handler. That's why I said you were working on something similar in PR #10275.

Copy link
Contributor Author

@pwhelan pwhelan May 14, 2025

Choose a reason for hiding this comment

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

That was an experiment to see what could be done to avoid using atomic variables as signal flags. I obvioulsy crashed head first into the fact that EINTR will interrupt and basically drop the events from the queue before they can be emitted.

I think the only real way around using atomic variables will be to add support for signal events to monkey. I was hoping to avoid it but I at least cannot see another way through.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's why I tagged you in that other PR.

I think what he did with the signal queue is correct but we need to do it using the platform agnostic atomic operation wrapper which we need to move from cmetrics to cfl (I thought that was already done but it seems I was wrong).

I think with that, the signal mask tweak and a bit of elbow grease to ensure that the mechanism is tidy we should be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Were you able to make any progress on this? Do you need anything from me?

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.

3 participants