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

"install -f" uses exec to uninstall an existing agent #4965

Merged
merged 18 commits into from
Jun 28, 2024

Conversation

michel-laterman
Copy link
Contributor

@michel-laterman michel-laterman commented Jun 19, 2024

What does this PR do?

When elastic-agent install -f is ran, and an agent install has been detected, exec elastic-agent uninstall -f instead of calling Uninstall from within the Install func.

This causes the uninstall process to use paths associated with the installed agent binary instead of paths associated with the agent running the install command.

Why is it important?

If an agent with tamper protection (with the defend integration) is installed, the defend integration can be orphaned by using the a --force/-f flag with the install command.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

install -f by default will use the existing system's agent to perform the uninstall. Using the system's agent to uninstall can fail if we introduce regression into the uninstall process in a future release.
The --run-uninstall-from-binary flag has been provided to restore old behaviour, but is hidden as it's considered an advanced option that can orphan the endpoint component.

How to test this PR locally

Enroll the agent with a policy that contains the defend integration and has tamper protection enabled.

Attempt to re-install (using the -f flag) into another policy.

With the changes the output is:

sudo ./elastic-agent install --url=https://40934063fedc40cb9408d7c9c9000b2b.fleet.us-central1.gcp.foundit.no:443 --enrollment-token=OVNydk81QUJYZ2tNazd2U3NaLXk6b3dSblc2QUhSaW1jdjQ0ZHdvUE5Edw==  -f
[   =] Service Started  [6s] Elastic Agent successfully installed, starting enrollment.
[==  ] Waiting For Enroll...  [7s] {"log.level":"info","@timestamp":"2024-06-26T11:30:57.976-0700","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":518},"message":"Starting enrollment to URL: https://40934063fedc40cb9408d7c9c9000b2b.fleet.us-central1.gcp.foundit.no:443/","ecs.version":"1.6.0"}
[=   ] Waiting For Enroll...  [8s] {"log.level":"info","@timestamp":"2024-06-26T11:30:59.726-0700","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).daemonReloadWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":481},"message":"Restarting agent daemon, attempt 0","ecs.version":"1.6.0"}
[    ] Waiting For Enroll...  [8s] {"log.level":"info","@timestamp":"2024-06-26T11:30:59.765-0700","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).Execute","file.name":"cmd/enroll_cmd.go","file.line":299},"message":"Successfully triggered restart on running Elastic Agent.","ecs.version":"1.6.0"}
Successfully enrolled the Elastic Agent.
[    ] Done  [8s]
Elastic Agent has been successfully installed.

sudo ./elastic-agent install --url=https://40934063fedc40cb9408d7c9c9000b2b.fleet.us-central1.gcp.foundit.no:443 --enrollment-token=MGlyT081QUJYZ2tNazd2UzFwNmc6RU11QlNodWpRT2FXbDJEam9zYVQ5QQ== -f
[=== ] Failed to uninstall service  [2s] failed to uninstall component "endpoint-default": error uninstalling service: 2024-06-26 18:33:26: error: InstallLib.cpp:1231 Invalid uninstall token: exit status 28
[==  ] Failed to uninstall agent  [2s] Error uninstalling. Printing logs
2024-06-26T18:33:25.310Z	DEBUG	[uninstall.state_migration]	state store /opt/Elastic/Agent/data/elastic-agent-8.15.0-SNAPSHOT-2a527d/state.enc already exists
2024-06-26T18:33:25.409Z	DEBUG	[uninstall.composable]	Starting controller for composable inputs
2024-06-26T18:33:25.409Z	DEBUG	[uninstall.composable]	Started controller for composable inputs
2024-06-26T18:33:25.410Z	DEBUG	[uninstall.composable.providers.kubernetes]	Kubernetes provider for resource pod skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-26T18:33:25.410Z	DEBUG	[uninstall.composable.providers.kubernetes]	Kubernetes provider for resource node skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-26T18:33:25.410Z	DEBUG	[uninstall.composable]	Variable state changed for composable inputs; debounce started
2024-06-26T18:33:25.411Z	DEBUG	[uninstall.composable]	Kubernetes leaderelection provider skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-26T18:33:25.411Z	DEBUG	[uninstall.composable]	kubernetes_secrets provider skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-26T18:33:25.412Z	INFO	[uninstall.composable.providers.docker]	Docker provider skipped, unable to connect: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
2024-06-26T18:33:25.537Z	DEBUG	[uninstall.composable]	Computing new variable state for composable inputs
2024-06-26T18:33:25.538Z	DEBUG	[uninstall.composable]	Stopping controller for composable inputs
2024-06-26T18:33:25.634Z	DEBUG	[uninstall.composable]	Stopped controller for composable inputs
2024-06-26T18:33:25.689Z	INFO	[uninstall]	Capabilities file not found in /opt/Elastic/Agent/capabilities.yml
2024-06-26T18:33:25.690Z	DEBUG	[uninstall]	uninstall endpoint-security service
2024-06-26T18:33:26.843Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: ProcFile.cpp:855 Found 1 cgroups for pid(11143)	{"context": "command output"}
2024-06-26T18:33:26.844Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: ProcFile.cpp:861 cgroup: id=0 type= path=/user.slice/user-1000.slice/session-25.scope	{"context": "command output"}
2024-06-26T18:33:26.844Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: MainPosix.cpp:262 Executing uninstall	{"context": "command output"}
2024-06-26T18:33:26.844Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: VaultLib.cpp:207 Vault initialized with existing seed file	{"context": "command output"}
2024-06-26T18:33:26.857Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: VaultLib.cpp:612 Successfully read vault key: config	{"context": "command output"}
2024-06-26T18:33:26.859Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: ECSUtilities.cpp:420 Tamper protection enabled	{"context": "command output"}
2024-06-26T18:33:26.859Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: InstallLib.cpp:951 Checking installed uninstall protection artifacts	{"context": "command output"}
2024-06-26T18:33:26.889Z	ERROR	[uninstall]	2024-06-26 18:33:26: debug: VaultLib.cpp:612 Successfully read vault key: config	{"context": "command output"}
2024-06-26T18:33:26.890Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: InstallLib.cpp:710 No custom public key detected in Endpoint config	{"context": "command output"}
2024-06-26T18:33:26.891Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: CryptoLib.cpp:1460 RSA signature verified	{"context": "command output"}
2024-06-26T18:33:26.892Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: InstallLib.cpp:883 Failed to read os section of tamper-protection-config, continuing	{"context": "command output"}
2024-06-26T18:33:26.892Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: InstallLib.cpp:972 Finished checking installed uninstall protection artifacts with result deny	{"context": "command output"}
2024-06-26T18:33:26.892Z	ERROR	[uninstall]	2024-06-26 18:33:26: info: InstallLib.cpp:1044 Finished checking command line provided uninstall resource result deny	{"context": "command output"}
2024-06-26T18:33:26.892Z	ERROR	[uninstall]	2024-06-26 18:33:26: error: InstallLib.cpp:1231 Invalid uninstall token	{"context": "command output"}
Error: error uninstalling agent: error uninstalling components: error uninstalling component: error uninstalling service: 2024-06-26 18:33:26: error: InstallLib.cpp:1231 Invalid uninstall token: exit status 28
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.15/fleet-troubleshooting.html
[   =] Uninstall failed  [2s] Error: failed to uninstall elastic-agent: exit status 1
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.15/fleet-troubleshooting.html

Related issues

@michel-laterman michel-laterman added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-v8.14.0 Automated backport with mergify labels Jun 19, 2024
@michel-laterman michel-laterman requested a review from a team as a code owner June 19, 2024 21:49
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@cmacknz
Copy link
Member

cmacknz commented Jun 20, 2024

This should have a simple integration test to ensure install -f fails without the tamper protection token. This check can probably just be added to one of the existing endpoint security tests. https://github.com/elastic/elastic-agent/blob/main/testing/integration/endpoint_security_test.go

@michel-laterman
Copy link
Contributor Author

Looks like the integration tests are failing because if this change:

Test:       	TestLogIngestionFleetManaged
--
  | >>> (linux-amd64-ubuntu-2404-fleet) Test output (sudo) (stdout): Messages:   	uninstalling agent failed. Output: "\r[    ] Failed to uninstall agent  [0s] Error uninstalling. Printing logs\nError: error uninstalling agent: tamper protection detected, elastic-agent uninstall command must be ran with a valid --uninstall-token arg: missing uninstall token\nFor help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.15/fleet-troubleshooting.html\n"
  | >>> (linux-amd64-ubuntu-2404-fleet) Test output (sudo) (stdout): fixture_install.go:253:

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good. Please ensure integration tests exist for requiring the flag, and a test for not requiring the flag.

@ycombinator
Copy link
Contributor

ycombinator commented Jun 21, 2024

@elastic/support-tech-leads Heads up on the change of behavior as described in the Disruptive User Impact section of this bugfix PR.

@lucabelluccini
Copy link
Contributor

Hello @ycombinator - huge thanks for the heads up. May I kindly request 2 things:

@cmacknz
Copy link
Member

cmacknz commented Jun 24, 2024

Trying this out with an 8.14.1 agent using a policy with tamper protection enabled. Running the uninstall command fails when I omit the uninstall token with the expected error, but a force install succeeds with an orphaned endpoint as captured in the issue.

An uninstall -f seems to hit a completely different code path than install -f. I think that is the root of the problem. The install -f should fail in the exact same way. It isn't enough to check for uninstall token, it needs to also fail if the token is invalid. Possibly the difference is uninstall knows it is interacting with a live agent and install doesn't.

ubuntu@suave-ling:~/elastic-agent-8.14.1-linux-arm64$ sudo elastic-agent uninstall -f
[==  ] Failed to uninstall service  [1s] failed to uninstall component "endpoint-default": error uninstalling service: 2024-06-24 19:55:42: error: InstallLib.cpp:1253 Invalid uninstall token: exit status 28
[==  ] Failed to uninstall agent  [1s] Error uninstalling. Printing logs
2024-06-24T19:55:41.942Z        DEBUG   [uninstall.state_migration]     state store /opt/Elastic/Agent/data/elastic-agent-8.14.1-1348b9/state.enc already exists
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable]  Starting controller for composable inputs
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable]  Started controller for composable inputs
2024-06-24T19:55:41.949Z        INFO    [uninstall.composable.providers.docker] Docker provider skipped, unable to connect: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable]  Variable state changed for composable inputs; debounce started
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable]  kubernetes_secrets provider skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable]  Kubernetes leaderelection provider skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable.providers.kubernetes]     Kubernetes provider for resource pod skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-24T19:55:41.949Z        DEBUG   [uninstall.composable.providers.kubernetes]     Kubernetes provider for resource node skipped, unable to connect: unable to build kube config due to error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
2024-06-24T19:55:42.056Z        DEBUG   [uninstall.composable]  Computing new variable state for composable inputs
2024-06-24T19:55:42.056Z        DEBUG   [uninstall.composable]  Stopping controller for composable inputs
2024-06-24T19:55:42.181Z        DEBUG   [uninstall.composable]  Stopped controller for composable inputs
2024-06-24T19:55:42.191Z        INFO    [uninstall]     Capabilities file not found in /opt/Elastic/Agent/capabilities.yml
2024-06-24T19:55:42.192Z        DEBUG   [uninstall]     uninstall endpoint-security service
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: debug: ProcFile.cpp:855 Found 1 cgroups for pid(7628)      {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: debug: ProcFile.cpp:861 cgroup: id=0 type= path=/user.slice/user-1000.slice/session-99.scope       {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: MainPosix.cpp:262 Executing uninstall        {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: Internal.cpp:51 Found config path [/opt/Elastic/Endpoint/elastic-endpoint.yaml]      {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: debug: ECSUtilities.cpp:420 Tamper protection enabled      {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: InstallLib.cpp:961 Checking installed uninstall protection artifacts {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: Internal.cpp:51 Found config path [/opt/Elastic/Endpoint/elastic-endpoint.yaml]      {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: InstallLib.cpp:720 No custom public key detected in Endpoint config  {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: CryptoLib.cpp:1460 RSA signature verified    {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: InstallLib.cpp:893 Failed to read os section of tamper-protection-config, continuing {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: InstallLib.cpp:982 Finished checking installed uninstall protection artifacts with result deny       {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: info: InstallLib.cpp:1054 Finished checking command line provided uninstall resource result deny   {"context": "command output"}
2024-06-24T19:55:42.207Z        ERROR   [uninstall]     2024-06-24 19:55:42: error: InstallLib.cpp:1253 Invalid uninstall token {"context": "command output"}
Error: error uninstalling agent: error uninstalling components: error uninstalling component: error uninstalling service: 2024-06-24 19:55:42: error: InstallLib.cpp:1253 Invalid uninstall token: exit status 28
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.14/fleet-troubleshooting.html

ubuntu@suave-ling:~/elastic-agent-8.14.1-linux-arm64$ sudo ./elastic-agent install -f
[  ==] Service Started  [5s] Elastic Agent successfully installed, starting enrollment.
[  ==] Done  [5s]
Elastic Agent has been successfully installed.

@michel-laterman
Copy link
Contributor Author

michel-laterman commented Jun 25, 2024

Running sudo elastic-agent uninstall gives the paths as config=/opt/Elastic/Agent/elastic-agent.yml top=/opt/Elastic/Agent

Running sudo ./elastic-agent install -f gives the paths as: config=$ARCHIVE_DIR/elastic-agent.yml top=/opt/Elastic/Agent

So it looks like the Uninstall that the install command calls if an install is detected passes the wrong config file. However the code shortcut paths.ConfigFile() returns $ARCHIVE_DIR/elastic-agent.yml when called by the install command.

EDIT: ensuring that the uninstall configs match does not fix the issue

@michel-laterman
Copy link
Contributor Author

When install -f tries to uninstall the agent, it detects no components and returns in:

if len(comps) == 0 {
return nil
}

@cmacknz
Copy link
Member

cmacknz commented Jun 25, 2024

Ah, that seems like the real underlying source of the bug.

Change the approach that is taken when "elastic-agent install -f" is ran
to use an exec to run "elastic-agent uninstall -f" in cases where the
agent is installed. this allows the process that runs the uninstall to
use all the correct path values for the installed agent instead of the
values associated with the binary that the install command is ran from.
// Uninstall will fail on protected agent.
// The protected Agent will need to be uninstalled first before it can be installed.
pt.Describe("Uninstalling current Elastic Agent")
err = Uninstall(cfgFile, topPath, "", log, pt)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously this call to uninstall was failing because paths.Components() would use a value that reflected the location from where elastic-agent install -f was being ran and not the installed agent.
This would result in the uninstall detecting 0 components, and skipping calling uninstall on each of the services, so endpoint uninstall was never called

@michel-laterman michel-laterman force-pushed the tamper-cheeck-unintall branch from 629dde3 to b210ac2 Compare June 25, 2024 20:59
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

There is one large side-effect to this change. Before this change it was actually the new version of the Elastic Agent performing the uninstallation. With this change now only the installed Elastic Agent is performing the uninstallation. The issue with that is that if there is a bug or issue in the currently installed Elastic Agent that prevents it from uninstalling, then the user is now really stuck.

I like this change and believe it is the correct change, but I do wonder if an optional flag should be added to allow it to uninstall the old-way just in-case? @cmacknz

Comment on lines 227 to 243
args := []string{
"uninstall",
"--force",
}
execPath, err := exec.LookPath(paths.BinaryName)
if err != nil {
return fmt.Errorf("unable to find %s on path: %w", paths.BinaryName, err)
}
uninstall := exec.Command(execPath, args...)
uninstall.Stdout = streams.Out
uninstall.Stderr = streams.Err
if err := uninstall.Start(); err != nil {
return fmt.Errorf("unable to start elastic-agent uninstall: %w", err)
}
if err := uninstall.Wait(); err != nil {
return fmt.Errorf("failed to uninstall elastic-agent: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should move this to its own function. Then cleanup the errors to be more generic in the function and then wrap the error output like so:

err := performUninstall(...)
if err != nil {
    return fmt.Errorf("failed to uninstall current Elastic Agent: %w", err)
}

That ensures that the error back to the user is clear that its failing installing the currently installed Elastic Agent.

@jlind23
Copy link
Contributor

jlind23 commented Jun 26, 2024

I like this change and believe it is the correct change, but I do wonder if an optional flag should be added to allow it to uninstall the old-way just in-case? @cmacknz

I wonder if this wouldn't leave a security flaw but I agree that having an escape hatch in such case would be nice anyway.

@cmacknz
Copy link
Member

cmacknz commented Jun 26, 2024

I wonder if this wouldn't leave a security flaw but I agree that having an escape hatch in such case would be nice anyway.

The old way would be leaving an orphaned endpoint process behind that cannot get configuration updates from agent. On Linux for example this is the same result you get if you run systemctl stop elastic-agent, but we shouldn't make it easy to create this state with a common operation.

What we should do is make it possible to run uninstall and ignore every error except tamper protection errors. Most of our recent pain has been around removing files on Windows with the dreaded "access is denied" error. Ignoring something like that is fine.

@michel-laterman michel-laterman changed the title Add explicit check for token and tamper protection in Uninstall func "install -f" uses exec to uninstall an existing agent Jun 27, 2024
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good. Just add hide the extra flag, as discuss in the weekly.

internal/pkg/agent/cmd/install.go Show resolved Hide resolved
@michel-laterman
Copy link
Contributor Author

buildkite test this

@blakerouse
Copy link
Contributor

@michel-laterman SonarQube is blocking your PR, but everything else looks good. You are going to need to get @ycombinator, @pierrehilbert, or @cmacknz to perform the merge because of it.

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
5.9% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@ycombinator
Copy link
Contributor

@michel-laterman SonarQube is blocking your PR, but everything else looks good. You are going to need to get @ycombinator, @pierrehilbert, or @cmacknz to p

Acknowledged. Will merge once Buildkite statuses are green.

@ycombinator ycombinator merged commit 1d7b865 into elastic:main Jun 28, 2024
12 of 13 checks passed
mergify bot pushed a commit that referenced this pull request Jun 28, 2024
* Add explicit check for token and tamper protection in Uninstall func

* fix typo

* Load features from config, fix protection flag load

* Change approach to execute elastic-agent uninstall command

Change the approach that is taken when "elastic-agent install -f" is ran
to use an exec to run "elastic-agent uninstall -f" in cases where the
agent is installed. this allows the process that runs the uninstall to
use all the correct path values for the installed agent instead of the
values associated with the binary that the install command is ran from.

* Add e2e test

* lookup agent binary on path, fix test

* fix test

* Add flag that preserves old approach

* fix typo

* change args format in test

* Use same fixture

* Hide new option

---------

Co-authored-by: Julien Lind <[email protected]>
(cherry picked from commit 1d7b865)

# Conflicts:
#	internal/pkg/agent/cmd/install.go
#	testing/integration/endpoint_security_test.go
@michel-laterman michel-laterman deleted the tamper-cheeck-unintall branch June 28, 2024 18:41
jlind23 pushed a commit that referenced this pull request Jul 5, 2024
…g agent (#5021)

* "install -f" uses exec to uninstall an existing agent (#4965)

* Add explicit check for token and tamper protection in Uninstall func

* fix typo

* Load features from config, fix protection flag load

* Change approach to execute elastic-agent uninstall command

Change the approach that is taken when "elastic-agent install -f" is ran
to use an exec to run "elastic-agent uninstall -f" in cases where the
agent is installed. this allows the process that runs the uninstall to
use all the correct path values for the installed agent instead of the
values associated with the binary that the install command is ran from.

* Add e2e test

* lookup agent binary on path, fix test

* fix test

* Add flag that preserves old approach

* fix typo

* change args format in test

* Use same fixture

* Hide new option

---------

Co-authored-by: Julien Lind <[email protected]>
(cherry picked from commit 1d7b865)

# Conflicts:
#	internal/pkg/agent/cmd/install.go
#	testing/integration/endpoint_security_test.go

* cleanup

---------

Co-authored-by: Michel Laterman <[email protected]>
Co-authored-by: michel-laterman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.14.0 Automated backport with mergify bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent install -f Leaves Orphaned Tamper-Protected Endpoint
8 participants