Skip to content
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

refactor(libsinsp): remove cri extern variables #1541

Merged
merged 7 commits into from
Jan 16, 2024

Conversation

therealbobo
Copy link
Contributor

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

Any specific area of the project related to this PR?

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

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:

This removes the extern cri variables in attempt to make libsinsp more maintainable.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@incertum
Copy link
Contributor

incertum commented Dec 4, 2023

@therealbobo starting some better unit tests for the container engine, will tag you. We should add some more tests as we change things around in the container engine going forward.

@Andreagit97 Andreagit97 added this to the 0.15.0 milestone Dec 11, 2023
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
@therealbobo therealbobo marked this pull request as ready for review January 5, 2024 09:37
@poiana poiana requested a review from LucaGuerra January 5, 2024 09:37
@therealbobo therealbobo changed the title refactor(libsinsp): remove cri extern variables wip: refactor(libsinsp): remove cri extern variables Jan 5, 2024
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
@therealbobo therealbobo changed the title wip: refactor(libsinsp): remove cri extern variables refactor(libsinsp): remove cri extern variables Jan 5, 2024
settings::~settings()
{ }

settings* settings::s_instance = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as other PR, do we need raw pointers? If possible smart pointers going forward in libs, we have bee burnt a few times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fundamental problem is that the adoption of smart pointers requires having at least the dtor public which totally defeats the settings singleton 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

First time I hear that the destructor would need to be private. For example, checkout sinsp_dns_manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem here is that I didn't take the static local variable approach (like Meyer's Singleton) but, instead, I went for a more straightforward singleton with a static variable in the global scope. Do you know if the static local variable approach guarantees the uniqueness of the object in all the cases? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the additional comment @therealbobo let's collectively check what the best approach would be here. Maybe the other maintainers have preferences as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thought more about it and I would prefer a static get() function that returns a reference to a std::unique_ptr similar to the existing sinsp_dns_manager. Reasons being that we adopt a more consistent style throughout the code base and we discussed in previous core maintainers meetings that we won't accept raw pointers anymore going forward unless absolutely necessary, which I believe we don't have a strong case here for an exception. WDYT?

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Copy link
Contributor

@incertum incertum left a comment

Choose a reason for hiding this comment

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

Thanks @therealbobo LGTM, now just need to overcome the CI.


*/

#include <gtest/gtest.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if the CI failures are related to that, but I recall there were hiccups including the cri.hpp, e.g. see

#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__) // MINIMAL_BUILD and emscripten don't support containers at all

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Copy link
Contributor

@incertum incertum left a comment

Choose a reason for hiding this comment

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

/approve

Thanks @therealbobo!

@poiana
Copy link
Contributor

poiana commented Jan 11, 2024

LGTM label has been added.

Git tree hash: 338039d9c9a6900150c21149f4e7da247035f26b

Copy link
Contributor

@jasondellaluce jasondellaluce 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 Jan 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: incertum, jasondellaluce, therealbobo

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:
  • OWNERS [incertum,jasondellaluce]

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 48277b1 into falcosecurity:master Jan 16, 2024
28 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.

5 participants