elastic / elastic/elastic-agent
[Fleet] Solution to avoid duplicate agents
- Dominant language
- Go
- Stars
- 275
- Forks
- 264
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 312
Description
TL;DR: We need a way to properly unenroll an agent from command line on the client side, to be able to enroll it again without creating duplicates.
The use-case : an agent is having some issue, it shows as `updating` from the Fleet UI. Naturally, one tries to enroll the same agent again from client's command line.
For this:
- if we use `enroll` or `install -f` commands : it creates a duplicate agent in Fleet -not good.
- If we use `install` without `-f` option, we would get `Error: already installed at: /Library/Elastic/Agent`, and this would be stuck there without ability to enroll the agent. Not using `-f` is also not ideal when they have a simple script with the commands to run.
The goal here is to be able to re-enroll the agent without it creating duplicates.
So the only option we have left would be to go to Fleet UI, unenroll the agent. And once successfully unenrolled, then only we can try to enroll it from agent command line. The process of having to go through Fleet UI to do this can be considered cumbersome.
I think the solution to this problem could take multiple forms, and one of them would be to add an option to the enroll/install commands where the user can decide what to do in case an existing agent is already found: (either create a duplicate, unenroll the existing one and enroll again, or don't enroll and continue).
Contributor guide
Research direction
Start by locating the command-line entry points for the enroll and install commands and trace how an already-installed agent is handled. Compare the current duplicate-creation and already-installed paths, then define and verify a re-enrollment behavior that avoids creating duplicate Fleet agents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100