-
Notifications
You must be signed in to change notification settings - Fork 116
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
Remove created agents in service deployer #1771
Conversation
Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#9604 |
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#9604 |
💔 Build Failed
Failed CI StepsHistory
cc @mrodm |
After testing with the integrations repository, it was noticed that The error raised when testing in that data stream was:
To avoid this kind of errors, in those scenarios where new Elastic Agents are created, those agents will be enrolled using the new Agent Policy created in each test. Changes done in 096811f Updated description accordingly. |
if !r.options.RunIndependentElasticAgent { | ||
r.removeAgentHandler = func(ctx context.Context) error { | ||
// When not using independent agents, service deployers like kubernetes or custom agents create new Elastic Agent | ||
createdNewAgent := svcInfo.Agent.Host.NamePrefix == "docker-custom-agent" || svcInfo.Agent.Host.NamePrefix == "kind-control-plane" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Depending on the name of the agent may be fragile, we may forget to modify this if the set of names change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add a new field into svcInfo
to set whether or not this service requires a new Agent (different from the stack).
Maybe something like this (adding Stack field) ?
Agent struct { |
// Agent related properties.
Agent struct {
// Host describes the machine which is running the agent.
Host struct {
// Name prefix for the host's name
NamePrefix string
}
// Stack indicates whether or not this Agent is the one running/set in "elastic-package stack up"
Stack bool
}
WDYT @jsoriano ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe change it to be Independent
svcInfo.Agent.Independent
(true or false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both options SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, I'll merge this PR as it is then, and I'll create a follow-up PR to remove those agent names with one of these options and run the tests with integrations again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created PR #1776
Part of #787
Currently, service deployers like
custom_agent
orkubernetes
create new Elastic Agent instances and those agents are never removed (nor unenrolled) from Fleet once the tests are finished (system tests).This PR removes these Elastic Agents created during tests from Fleet, so the stack state after running the tests is always without those Elastic Agents.
Moreover, to avoid errors like this if it is a long test execution:
Those new Elastic Agents are enrolled directly with the test Agent Policy created in each test.