Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented May 3, 2024

Relates #787
Closes #1586

This PR allows to spin up new Elastic agents independents from the Elastic Agent run in the stack (from elastic-package stack up command) for testing, if the packages defined in their manifest agent.privileges.root key as true.

That action can be overwritten if it is needed by setting the ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT environment variable. This variable has preference over the manifest file.

NOTE: if packages contain a folder to deploy a previous "custom agent" (_dev/deploy/agent), elastic-package will not create an independent Elastic Agent with User root. In that scenario, elastic-package will still create the previous custom agents.

@mrodm mrodm self-assigned this May 3, 2024
@mrodm mrodm changed the title Enable independent agent if root privileges is set to true Enable independent Elastic Agent if root privileges is set to true May 3, 2024
@@ -1,15 +1,17 @@
format_version: 1.0.0
format_version: 2.12.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update manifest to add agent.privileges.root key. This package keeps the custom agent (from servicedeployer).

Copy link
Member

Choose a reason for hiding this comment

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

Ok, looking at this, we can probably remove the custom agent, and the auditd_manager_independent_agent test package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering if we should keep that package to test the scenario of the custom agents. Although, oracle package is still there in this test folder.

If we remove the custom-agent folder of auditd_manager, we should add the settings into the system configuration file at least to add the capabilities required for the process.

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 guess we can do that. But as you prefer, having both packages also makes sense.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Nice!

}

runIndependentElasticAgent := false
// Enable independent agents if package defines that requires root privileges
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can mention here that this is temporary till independent agents are enabled by default.

@@ -1,15 +1,17 @@
format_version: 1.0.0
format_version: 2.12.0
Copy link
Member

Choose a reason for hiding this comment

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

Ok, looking at this, we can probably remove the custom agent, and the auditd_manager_independent_agent test package.

@mrodm mrodm marked this pull request as ready for review May 3, 2024 11:46
@mrodm mrodm requested a review from jsoriano May 3, 2024 11:46
@mrodm
Copy link
Contributor Author

mrodm commented May 3, 2024

It needs to take into account that if any package contains a folder to deploy a previous "custom agent" (_dev/deploy/agent), elastic-package will not create an independent Elastic Agent with User root. In that scenario, elastic-package will still create the previous custom agents. cc @jsoriano

Updated the description also with this note.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

🎉

elif [ "${PACKAGE_TEST_TYPE:-other}" == "with-logstash" ] && [ "${package_to_test}" == "system_benchmark" ]; then
elastic-package benchmark system --benchmark logs-benchmark -v --defer-cleanup 1s
else
if [[ "${ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT}" == "false" && "${package_to_test}" == "auditd_manager_independent_agent" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Umm, this auditd_manager_independent_agent package could be moved out of the with-custom-agent directory, right? And then maybe renamed back to auditd_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.

Ok, moving this package out of this folder 👍

@jsoriano
Copy link
Member

jsoriano commented May 3, 2024

It needs to take into account that if any package contains a folder to deploy a previous "custom agent" (_dev/deploy/agent), elastic-package will not create an independent Elastic Agent with User root. In that scenario, elastic-package will still create the previous custom agents. cc @jsoriano

The only custom agent that requires root is the one for auditd_manager, and it correctly defines the user and capabilities it requires, this will continue to be honored, right?

@mrodm
Copy link
Contributor Author

mrodm commented May 3, 2024

The only custom agent that requires root is the one for auditd_manager, and it correctly defines the user and capabilities it requires, this will continue to be honored, right?

Yes, that will be honored. elastic-package will create a custom agent (same as before) for that package with the capabilities and user defined in that YAML file.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm
Copy link
Contributor Author

mrodm commented May 3, 2024

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9783

@mrodm
Copy link
Contributor Author

mrodm commented May 3, 2024

The only custom agent that requires root is the one for auditd_manager, and it correctly defines the user and capabilities it requires, this will continue to be honored, right?

Yes, that will be honored. elastic-package will create a custom agent (same as before) for that package with the capabilities and user defined in that YAML file.

Just tested with this PR elastic/integrations#9783
Among the packages that define agent.privileges.root as true:

  • the following packages create independent Elastic Agent containers:
    • network_traffic
    • system_auditd
    • fim
  • Package auditd_manager keeps creating the previous custom Elastic Agent container (from servicedeployer).
  • Package universal_profiling_agent does not have any system tests.

@mrodm mrodm merged commit 48a4da9 into elastic:main May 3, 2024
@mrodm mrodm deleted the enable-independent-agent-root-privileges branch May 3, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[System tests] Run system tests for integrations with a non root Elastic Agent

3 participants