Skip to content

fix(userspace/falco): fix outputs_http timeout #3523

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

Merged
merged 3 commits into from
Apr 29, 2025

Conversation

benierc
Copy link
Contributor

@benierc benierc commented Apr 3, 2025

libcurl timeout prevent to send alert through http keep trying to send the alert

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

/kind release

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area engine

/area tests

/area proposals

/area CI

What this PR does / why we need it:

this PR ignore http_output libcurl timeout when network is not available,
it allows to send the alert when network is back and to not lost it

Which issue(s) this PR fixes:

Fixes #3522

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@poiana
Copy link
Contributor

poiana commented Apr 3, 2025

Welcome @benierc! It looks like this is your first PR to falcosecurity/falco 🎉

@poiana poiana added the size/XS label Apr 3, 2025
@poiana poiana requested review from FedeDP and Kaizhe April 3, 2025 09:50
Comment on lines 108 to 110
do {
res = curl_easy_perform(m_curl);
} while(res == CURLE_OPERATION_TIMEDOUT);
Copy link
Contributor

Choose a reason for hiding this comment

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

The change is fine but we'd better avoid a (possibly) infinite loop here. What about making the number of loops configurable through the Falco config file?
Eg: http_output.max_consecutive_timeouts (https://github.com/falcosecurity/falco/blob/master/falco.yaml#L726); a value like 5/10 by default is enough i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes good point i will try to add it

@FedeDP
Copy link
Contributor

FedeDP commented Apr 3, 2025

Thanks for the PR! I left a comment to avoid the unbound loop ;)
/milestone 0.41.0

@FedeDP
Copy link
Contributor

FedeDP commented Apr 7, 2025

Hi @benierc ! Great job! You need to update config json schema too with the new config key: https://github.com/falcosecurity/falco/blob/master/userspace/falco/config_json_schema.h

@benierc benierc force-pushed the master branch 3 times, most recently from 0dc7fbf to ae3dd2f Compare April 7, 2025 08:00
@@ -447,6 +447,11 @@ void falco_configuration::load_yaml(const std::string &config_name) {
keep_alive = m_config.get_scalar<bool>("http_output.keep_alive", false);
http_output.options["keep_alive"] = keep_alive ? std::string("true") : std::string("false");

uint32_t max_consecutive_timeouts;
max_consecutive_timeouts =
m_config.get_scalar<uint32_t>("http_output.max_consecutive_timeouts", 5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't m_max_consecutive_timeouts be enclosed in a range to avoid having an "almost" infinite loop if someone inputs a high value ?

Maybe also use a type smaller than unit32 to store it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i see, so an uint16_t or uint8_t should be better @sgaist ?

Copy link
Contributor

Choose a reason for hiding this comment

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

unit8's max being 255, I think it should already cover most use cases.

If there's a need in the future to have more than that number of retries, it's always possible to update at this time.

Copy link
Contributor

Choose a reason for hiding this comment

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

uint8_t makes sense IMHO!

Copy link
Contributor

@sgaist sgaist left a comment

Choose a reason for hiding this comment

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

Sorry, I just saw that my review wasn't submitted !

We're on the right track :-)

@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap Apr 11, 2025
@FedeDP
Copy link
Contributor

FedeDP commented Apr 23, 2025

The CI failures do not come from this PR! You will need to rebase once #3537 is merged :)

@FedeDP
Copy link
Contributor

FedeDP commented Apr 23, 2025

Ok the PR has been merged, you can rebase on top of master!

benierc and others added 3 commits April 24, 2025 09:12
libcurl timeout prevent to send alert through http
keep trying to send the alert

Signed-off-by: Clément Bénier <[email protected]>
Co-authored-by: Samuel Gaist <[email protected]>
Signed-off-by: benierc <[email protected]>
Co-authored-by: Federico Di Pierro <[email protected]>
Signed-off-by: benierc <[email protected]>
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Apr 24, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benierc, FedeDP

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana
Copy link
Contributor

poiana commented Apr 24, 2025

LGTM label has been added.

Git tree hash: 463e1390673a48f8651ac86223978e34c36b258a

@leogr leogr requested a review from sgaist April 28, 2025 09:09
@FedeDP
Copy link
Contributor

FedeDP commented Apr 29, 2025

@sgaist PTAL 🙏

Copy link
Contributor

@sgaist sgaist left a comment

Choose a reason for hiding this comment

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

LGTM

@poiana poiana merged commit 835ac52 into falcosecurity:master Apr 29, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

alert lost with http_output because of libcurl timeout
5 participants