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

[8.x](backport #4290) Add ability to enroll with a specific ID #4416

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 5, 2025

What is the problem this PR solves?

This solves an issue where an Elastic Agent is being replaced with a new Elastic Agent instance for the same host, pod, or workload. This allows the enrolling Elastic Agent to tell the ID that it wants to use, that ID can be currently in-use and this enrollment will take over the record of that Elastic Agent. To take off the existing Elastic Agent both the original and the new enrollment must use the same replace_token during the enrollment. This ensures that the original enrollment informs Fleet Server that it can be replaced, and ensures that the replacement has the same token to perform the replacement.

How does this PR solve the problem?

It solves the issue by taking a new id field in the enroll HTTP request. That id is then used as the Elastic Agent ID and determines if this is a new Elastic Agent or if it should take over an existing Elastic Agent record.

How to test this PR locally

At the moment the integration tests are the best way to test this, as the ability to use this field has not been exposed yet on the Elastic Agent.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc. (already covered by enroll handle)

Checklist

  • 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 (no config changes)
  • 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

Related issues

Add ability to enroll and provide the agent id as well as a replace-token to allow an existing agent to be replaced by a new agent that has the same agent id.

(cherry picked from commit 265bfbf)

# Conflicts:
#	NOTICE.txt
#	go.mod
@mergify mergify bot requested a review from a team as a code owner February 5, 2025 16:10
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Feb 5, 2025
@mergify mergify bot requested review from michalpristas and blakerouse February 5, 2025 16:10
Copy link
Contributor Author

mergify bot commented Feb 5, 2025

Cherry-pick of 265bfbf has failed:

On branch mergify/bp/8.x/pr-4290
Your branch is up to date with 'origin/8.x'.

You are currently cherry-picking commit 265bfbf.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1736300562-Add-ability-for-enrollment-to-take-an-agent-ID.yaml
	modified:   internal/pkg/api/error.go
	modified:   internal/pkg/api/handleEnroll.go
	modified:   internal/pkg/api/handleEnroll_test.go
	modified:   internal/pkg/api/openapi.gen.go
	modified:   internal/pkg/config/config_test.go
	modified:   internal/pkg/config/input.go
	new file:   internal/pkg/config/pbkdf2.go
	modified:   internal/pkg/dl/constants.go
	modified:   internal/pkg/model/schema.go
	modified:   internal/pkg/server/fleet_integration_test.go
	modified:   internal/pkg/server/namespaces_integration_test.go
	modified:   internal/pkg/server/remote_es_output_integration_test.go
	modified:   model/openapi.yml
	modified:   model/schema.json
	modified:   pkg/api/types.gen.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   NOTICE.txt
	both modified:   go.mod

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Feb 5, 2025
@blakerouse blakerouse removed the conflicts There is a conflict in the backported pull request label Feb 5, 2025
blakerouse
blakerouse previously approved these changes Feb 5, 2025
@blakerouse blakerouse enabled auto-merge (squash) February 5, 2025 18:47
@blakerouse blakerouse disabled auto-merge February 6, 2025 14:28
@blakerouse blakerouse enabled auto-merge (squash) February 6, 2025 15:38
@blakerouse blakerouse merged commit c7bf1a8 into 8.x Feb 6, 2025
9 checks passed
@blakerouse blakerouse deleted the mergify/bp/8.x/pr-4290 branch February 6, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 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.

2 participants