-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix(userspace/libsinsp): let plugins parse events before eventually filtering them out through inspector global filter #2182
Conversation
/milestone 0.20.0 |
} | ||
|
||
evt->set_filtered_out(false); | ||
const uint16_t etype = evt->get_scap_evt()->type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the parser is only responsible for the big switch case (ie: the actual parsing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the code below has been moved to a RAII oriented structure under sinsp.h: struct sinsp_evt_filter.
@@ -36,6 +36,7 @@ class sinsp_parser { | |||
void process_event(sinsp_evt* evt); | |||
void event_cleanup(sinsp_evt* evt); | |||
|
|||
bool reset(sinsp_evt* evt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is now called by sinsp, moved to public.
// | ||
// Run the state engine | ||
// | ||
m_parser->process_event(evt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep old behavior: only process event by sinsp if the event has not been filtered out.
// the internal implementation of libsinsp. | ||
for(auto& pp : m_plugin_parsers) { | ||
// todo(jason): should we log parsing errors here? | ||
pp.process_event(evt, m_event_sources); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For plugins, as stated by the comment, we cannot know in advance if an event will modify its state; therefore always call the plugin parsers.
Perf diff from master - unit tests
Heap diff from master - unit tests
Heap diff from master - scap file
Benchmarks diff from master
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2182 +/- ##
=======================================
Coverage 75.16% 75.17%
=======================================
Files 257 257
Lines 33711 33723 +12
Branches 5744 5743 -1
=======================================
+ Hits 25339 25350 +11
- Misses 8372 8373 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…iltering them out through inspector global filter. Signed-off-by: Federico Di Pierro <[email protected]>
…p.cpp. Signed-off-by: Federico Di Pierro <[email protected]> Co-authored-by: Jason Dellaluce <[email protected]>
28ae697
to
b162571
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, 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 |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Before, it was the sinsp parser that decided if an event was to be filtered out given the inspector global filter.
This led to a problem where the plugins were actually able to parse the event, but then the event was filtered out in any case.
For example, if we had a filter on a plugin field, we evaluated the filter before the plugin parsed the event, but if the plugin field extraction relied on the parsing code to eg: write a value to a foreign key, the filter would always filter out the event.
Eg (leveraging #2179):
The
container_plugin.id!=host
filter would have been evaluated before plugin parsers were called, leading tocontainer_plugin.id
beinghost
instead of the real container id for the very first event in a container (ie: the clone).Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: