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

Elastic Agent on Windows cannot be stopped or removed if --delay-enroll is retrying #4972

Open
strawgate opened this issue Jun 20, 2024 · 6 comments
Assignees
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Comments

@strawgate
Copy link

strawgate commented Jun 20, 2024

per elastic/elastic-stack-installers#277 and likely caused by #4800

The Elastic Agent on Windows is unable to be stopped after the service is started post a --delay-enroll installation if the enrollment cannot be completed.

To reproduce:

  1. Install the agent with --delay-enroll and a fake fleet server or bad key
  2. Restart the system or start the service in task manager
  3. Notice in the Agent log that the agent is failing to enroll
  4. Attempt to stop the agent via service manager or uninstall the agent via elastic-agent uninstall

The agent service should respond to stop requests even if enrollment is failing, and uninstall should not be blocked by bad enrollment information.

@strawgate strawgate added the bug Something isn't working label Jun 20, 2024
@jlind23 jlind23 added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jun 20, 2024
@elasticmachine
Copy link
Collaborator

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

@pierrehilbert
Copy link
Contributor

Unfortunately as I don't have a Windows setup I didn't test it but is it working if you are doing elastic-agent uninstall --force to force the uninstall?

@blakerouse
Copy link
Contributor

Interesting because the loop clearly watches for the context to be cancelled and doesn't continue. That context also gets cancelled when the signal is given to the process. This is strange behaviour:

for {
if ctx.Err() != nil {
return nil, ctx.Err()
}
err = c.Execute(ctx, cli.NewIOStreams())
if err == nil {
// enrollment was successful
break
}

@pierrehilbert
Copy link
Contributor

@blakerouse did you try to reproduce or not yet? (just for me to understand where we are with the investigations)

@blakerouse
Copy link
Contributor

I have not tried to reproduce, just providing code context. Some times these issues are easy to fix by just looking at the code and noticing an error.

@cmacknz
Copy link
Member

cmacknz commented Jun 24, 2024

As part of the original PR I did try this on a Windows machine and it let me uninstall: #4727 (comment)

However it is possible something has changed since I tested it originally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

No branches or pull requests

6 participants