Skip to content

cleanup(plugins/container): drop static vars#728

Merged
poiana merged 3 commits intofalcosecurity:mainfrom
FedeDP:cleanup/drop_static_vars
Apr 28, 2025
Merged

cleanup(plugins/container): drop static vars#728
poiana merged 3 commits intofalcosecurity:mainfrom
FedeDP:cleanup/drop_static_vars

Conversation

@FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Apr 28, 2025

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

/area plugins

What this PR does / why we need it:

The PR drops a useless static var in container plugin ASYNC capability.
Also, it properly checks for the only remaining static variable before using it.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

FedeDP added 3 commits April 28, 2025 13:30
Make it a class member.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Static-storage variables are correctly checked.
This can happend in 2 scenarios:
* sinsp erratingly calls multiple times start async API (should be a bug but better safe than sorry)
* Falco hot reload dry-run checks

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
project(
container
VERSION 0.2.0
VERSION 0.2.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bump to 0.2.1.

@poiana poiana added the size/S label Apr 28, 2025
Comment on lines +26 to +31
// We are already started. This can happen:
// * if `start_async_events` is called multiple times
// * during Falco hot reload dry-run checks; in that scenario,
// the same library object gets opened once again, thus a new `my_plugin`
// instance is created,
// and all static variables are shared. Just return true and do nothing.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is relevant comment.

nlohmann::json j(m_cfg);
const char *enabled_engines = nullptr;
s_async_ctx = StartWorker(generate_async_event<ASYNC_HANDLER_GO_WORKER>,
m_async_ctx = StartWorker(generate_async_event<ASYNC_HANDLER_GO_WORKER>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

s_async_ctx (static) -> m_async_ctx (member of my_plugin class).

@github-actions
Copy link

Rules files suggestions

@poiana
Copy link
Contributor

poiana commented Apr 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

Details 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 poiana merged commit b8140c8 into falcosecurity:main Apr 28, 2025
22 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.

3 participants