Skip to content

new: driver selection in falco.yaml#2413

Merged
poiana merged 29 commits intofalcosecurity:masterfrom
therealbobo:new/mode-in-config
Nov 27, 2023
Merged

new: driver selection in falco.yaml#2413
poiana merged 29 commits intofalcosecurity:masterfrom
therealbobo:new/mode-in-config

Conversation

@therealbobo
Copy link
Contributor

@therealbobo therealbobo commented Feb 9, 2023

Signed-off-by: Roberto Scolaro roberto.scolaro21@gmail.com

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:

It might be useful to configure the driver mode via the configuration file falco.yaml

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

new: driver selection in falco.yaml

@Andreagit97
Copy link
Member

Thank you for this! @therealbobo
We discussed many times to uniform how we open engines and this could be a possible way
cc @leogr

@leogr
Copy link
Member

leogr commented Feb 21, 2023

Thank you for this! @therealbobo We discussed many times to uniform how we open engines and this could be a possible way cc @leogr

It could be a possible solution. However, how could that option interact with other ways to select the driver?
I specifically refer to the FALCO_BPF_PROBE env var and other esoteric options like -u or how we enable the gVisor support.

Let's discuss it!

@therealbobo
Copy link
Contributor Author

therealbobo commented Feb 21, 2023

I think that the driver selected in falco.yaml should be considered if and only if the driver to be used is not specified in any other way (e.g. env variable or args). Moreover, using the config file, it will possibile to simplify the service management. 🤔

@leogr leogr added this to the 0.36.0 milestone May 3, 2023
@poiana
Copy link
Contributor

poiana commented Aug 1, 2023

Issues go stale after 90d of inactivity.

Mark the issue as fresh with /remove-lifecycle stale.

Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle stale

@FedeDP
Copy link
Contributor

FedeDP commented Nov 6, 2023

/reopen

/remove-lifecycle stale

@poiana poiana reopened this Nov 6, 2023
@poiana
Copy link
Contributor

poiana commented Nov 6, 2023

@FedeDP: Reopened this PR.

Details

In response to this:

/reopen

/remove-lifecycle stale

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@FedeDP
Copy link
Contributor

FedeDP commented Nov 6, 2023

/milestone 0.37.0

@poiana poiana modified the milestones: TBD, 0.37.0 Nov 6, 2023
@FedeDP
Copy link
Contributor

FedeDP commented Nov 6, 2023

We actually need this for the shiny new falco-driver-loader integrated inside falcoctl: falcosecurity/falcoctl#327

@FedeDP
Copy link
Contributor

FedeDP commented Nov 6, 2023

I'd suggest a rebase, and then:

  • DEPRECATION NOTICE for FALCO_BPF_PROBE
  • DEPRECATION NOTICE for cmd line options (note that -u was already dropped in the meantime, so i think that only the modern-bpf related one survives today)

Imho config option should always take precedence over deprecated cmdline/env var, since otherwise falcoctl would not be able to correctly instrument the right driver for Falco.

/cc @leogr

@FedeDP FedeDP force-pushed the new/mode-in-config branch from ef38a9f to 7b39c8e Compare November 22, 2023 14:35
Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

LGMT!

Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

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

Love this. It's a huge improvement, and we will finally get a bit of consistency across our configuration. So, first of all, a big thanks to @therealbobo, @Andreagit97, and @FedeDP 👏

The implementation is already good. I've just left some comments about minor issues I've found when reviewing.

Other than that, I want to ensure that a warning message is printed to the user any time a deprecated option is used (either command line or config). I've already identified a corner case (see my comment below) and I think another similar corner case can happen if the user modified both the old and the new field in the configuration file.

Ping me privately, I can provide more details if needed.

// at least one change in the default config we don't allow to use the command line options.
if(s.config->m_changes_in_engine_config)
{
return run_result::ok();
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with this behavior. However, I don't like silently ignoring deprecated options here (users may not get what's happening).

So, when the user mistakenly uses BOTH the command line flag AND change the config, we should print something like:

The '-g,--gvisor-config' command line option is deprecated and will be removed in Falco version 0.38. Note that this option is ineffective when 'engine' settings are specified via the configuration file.

Copy link
Contributor

@FedeDP FedeDP Nov 23, 2023

Choose a reason for hiding this comment

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

I'd add a single log, something like:

if(s.config->m_changes_in_engine_config)
	{
                 falco_logger::log(falco_logger::level::WARNING,
				  "Since the new 'engine' config key is being used, deprecated CLI options "
				  "[-e,-g,--gvisor-config,--nodriver,--modern-bpf] and FALCO_BPF_PROBE environment variable will be ignored.\n");
		return run_result::ok(); 

Copy link
Contributor

Choose a reason for hiding this comment

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

Added in latest commit; example output:

Thu Nov 23 15:15:50 2023: Falco version: 0.37.0-146+9bf0565 (x86_64)
Thu Nov 23 15:15:50 2023: Falco initialized with configuration file: ../falco.yaml
Thu Nov 23 15:15:50 2023: Since the new 'engine' config key is being used, deprecated CLI options [-e,-g,--gvisor-config,--nodriver,--modern-bpf] and FALCO_BPF_PROBE environment variable will be ignored.
Thu Nov 23 15:15:50 2023: Loading rules from file ../rules/falco_rules.yaml

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I was thinking of printing the warning only if one of those options was used. But your solution is fine anyway 👍


// If overridden from CLI options (soon to be removed),
// use the requested driver.
if (getenv(FALCO_BPF_ENV_VARIABLE))
Copy link
Member

Choose a reason for hiding this comment

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

What will happen when this gets merged, and perhaps some of the users will use the same env var in the config 👇 ?

engine:
  kind: kmod
  kmod:
    buf_size_preset: 4
    drop_failed_exit: false
  ebpf:
    # path to the elf file to load.
    probe: ${FALCO_BPF_PROBE}

🤯

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing, i mean the deprecated env variable takes precedence.

Copy link
Member

Choose a reason for hiding this comment

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

Nothing, i mean the deprecated env variable takes precedence.

Will it print a warning even if it shouldn't? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it will print the newly introduced warning about the fact that FALCO_BPF_PROBE env variable will be ignored, and that is correct(since we won't directly use the env variable but the new config key that resolves to the env variable value)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh i mis-read (i thought kind: bpf was in use). In this case, as i stated earlier, the deprecated env variable takes precedence (since the bpf kind configuration is not even parsed, because the kind is kmod).
No warning in this case (except for the FALCO_BPF_PROBE env var deprecation )

@FedeDP FedeDP force-pushed the new/mode-in-config branch from eb0689d to a8749b6 Compare November 23, 2023 14:57
Also, properly warn the user that deprecated CLI options will be ignored
when the new `engine` configuration key is in use.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
These macros will be used by other files so we need to share them

Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Copy link
Contributor

@LucaGuerra LucaGuerra left a comment

Choose a reason for hiding this comment

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

Thank you for this! 😮 LGTM, let's merge it so we can test it better. This is something we needed 😅

@poiana
Copy link
Contributor

poiana commented Nov 24, 2023

LGTM label has been added.

DetailsGit tree hash: f99a5c87c0a21f7dc134467c3c73787ba75ee22f

Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

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

For sure we need to deeply test it, but LGTM at the moment!

Thank you'll!

@poiana
Copy link
Contributor

poiana commented Nov 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, leogr, LucaGuerra, therealbobo

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:
  • OWNERS [Andreagit97,LucaGuerra,leogr]

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 00b7c56 into falcosecurity:master Nov 27, 2023
alacuku added a commit to alacuku/charts that referenced this pull request Jan 11, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
alacuku added a commit to alacuku/charts that referenced this pull request Jan 12, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
alacuku added a commit to alacuku/charts that referenced this pull request Jan 12, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
alacuku added a commit to alacuku/charts that referenced this pull request Jan 23, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
alacuku added a commit to alacuku/charts that referenced this pull request Jan 24, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
alacuku added a commit to alacuku/charts that referenced this pull request Jan 24, 2024
Please see: falcosecurity/falco#2413.

Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
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.

7 participants