Skip to content

fix(userspace/libsinsp): allow plugin filterchecks args to be both index or key #2280

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 1 commit into from
Feb 14, 2025

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Feb 12, 2025

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:

Plugin filterchecks support having an arg that is either index or key, but not both together; that's because we try to parse the [%arg] as index first, and if we are not able to, we throw an exception without further checking if we need to try to parse the arg as string key too.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(userspace/libsinsp): allow plugin filterchecks args to be both index or key

…dex or key.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@poiana
Copy link
Contributor

poiana commented Feb 12, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@FedeDP
Copy link
Contributor Author

FedeDP commented Feb 12, 2025

/milestone 0.21.0
/cc @leogr @jasondellaluce

@poiana poiana added the size/S label Feb 12, 2025
@poiana poiana added this to the 0.21.0 milestone Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.32%. Comparing base (51410de) to head (d81c9d4).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/plugin_filtercheck.cpp 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2280      +/-   ##
==========================================
- Coverage   75.33%   75.32%   -0.01%     
==========================================
  Files         280      280              
  Lines       34554    34556       +2     
  Branches     5901     5902       +1     
==========================================
  Hits        26031    26031              
- Misses       8523     8525       +2     
Flag Coverage Δ
libsinsp 75.32% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Perf diff from master - unit tests

    18.01%     +0.81%  [.] sinsp_threadinfo::get_main_thread
     7.27%     -0.57%  [.] sinsp::next
     3.90%     -0.38%  [.] next_event_from_file
     2.99%     +0.33%  [.] gzfile_read
     8.53%     +0.32%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release
     9.44%     -0.30%  [.] sinsp_thread_manager::create_thread_dependencies
     0.37%     +0.27%  [.] libsinsp::events::is_unknown_event
     0.77%     +0.23%  [.] sinsp::fetch_next_event
     0.96%     -0.22%  [.] std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>
     1.62%     +0.22%  [.] sinsp_thread_manager::get_thread_ref

Heap diff from master - unit tests

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                         Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                            +0.0100         +0.0101           144           146           144           146
BM_sinsp_split_median                                          +0.0147         +0.0148           144           146           144           146
BM_sinsp_split_stddev                                          -0.4743         -0.4731             2             1             2             1
BM_sinsp_split_cv                                              -0.4796         -0.4784             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0096         +0.0097            61            61            61            61
BM_sinsp_concatenate_paths_relative_path_median                -0.0156         -0.0155            62            61            62            61
BM_sinsp_concatenate_paths_relative_path_stddev                -0.9455         -0.9455             2             0             2             0
BM_sinsp_concatenate_paths_relative_path_cv                    -0.9460         -0.9461             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0092         +0.0093            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0092         +0.0093            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_stddev                   +0.7464         +0.7438             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       +0.7305         +0.7278             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0993         +0.0994            58            64            58            64
BM_sinsp_concatenate_paths_absolute_path_median                +0.0991         +0.0993            58            63            58            63
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.1792         -0.1819             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.2534         -0.2559             0             0             0             0
BM_sinsp_split_container_image_mean                            +0.1077         +0.1078           387           428           387           428
BM_sinsp_split_container_image_median                          +0.1109         +0.1110           387           429           387           429
BM_sinsp_split_container_image_stddev                          +0.7465         +0.7443             2             4             2             4
BM_sinsp_split_container_image_cv                              +0.5767         +0.5745             0             0             0             0

@@ -239,8 +244,10 @@ void sinsp_filter_check_plugin::extract_arg_index(std::string_view full_field_na
message = " has an invalid index argument not representable on 64 bit: ";
}
}
throw sinsp_exception(string("filter ") + string(full_field_name) + string(" ") +
m_field->m_name + message + m_argstr);
if(required) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't throw any exception in case the index is not required (ie: we want also to try to parse this arg as key).

@poiana poiana merged commit c7b8dba into master Feb 14, 2025
46 of 49 checks passed
@poiana poiana deleted the fix/support_both_index_key_args_plugin_filterchecks branch February 14, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants