Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Mar 4, 2025

Relates #2039
Follows #2409

Ensure Elastic Agent created when using Independent Agents (default method via r.setupAgent) is removed even if the service exists with error.

Example of Buildkite build where service containers fails (e.g. mysql) and the agent is not removed:
https://buildkite.com/elastic/integrations/builds/22965

One example of this scenario is when the service container cannot started (it exits with failure). In that case, the new Elastic Agent created was not removed in the tear down process and therefore the corresponding Agent policies were not able to be deleted.

This PR duplicates the call to checkEnrolledAgents just after setting up the Elastic Agent so even in the case setupService fails, the new Elastic Agent can be deleted in the tear down process.

It needs to be duplicated this call since r.setupService could create new agents in case of the kubernetes service deployer or the custom agents deployer (the latter is deprecated) if the Elastic Agent of the stack is used (disabled Independent Elastic Agents).

In this buildkite build (with the changes of this PR), mysql now reports the container exit as error in xUnit files:
https://buildkite.com/elastic/integrations/builds/22973

@mrodm
Copy link
Contributor Author

mrodm commented Mar 4, 2025

test integrations

@mrodm
Copy link
Contributor Author

mrodm commented Mar 4, 2025

test integrations

@elastic-vault-github-plugin-prod

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

@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 4, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

History

@mrodm mrodm marked this pull request as ready for review March 4, 2025 13:11
@mrodm mrodm requested a review from a team March 4, 2025 13:11
@mrodm mrodm merged commit 0b3cf8b into elastic:main Mar 4, 2025
3 checks passed
@mrodm mrodm deleted the add_remove_agent_handler branch March 4, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants