diff --git a/internal/servicedeployer/custom_agent.go b/internal/servicedeployer/custom_agent.go index f6cc5e2594..d326fccf59 100644 --- a/internal/servicedeployer/custom_agent.go +++ b/internal/servicedeployer/custom_agent.go @@ -189,6 +189,7 @@ func (d *CustomAgentDeployer) SetUp(ctx context.Context, svcInfo ServiceInfo) (D svcInfo.Port = svcInfo.Ports[0] } + svcInfo.Agent.Independent = true svcInfo.Agent.Host.NamePrefix = svcInfo.Name service.svcInfo = svcInfo return &service, nil diff --git a/internal/servicedeployer/info.go b/internal/servicedeployer/info.go index 252e743798..a577cff09e 100644 --- a/internal/servicedeployer/info.go +++ b/internal/servicedeployer/info.go @@ -63,6 +63,10 @@ type ServiceInfo struct { // Name prefix for the host's name NamePrefix string } + + // Independent indicates whether or not the Agent assigned to this service is set + // independently from the Elastic Agent running in the stack (elastic-package stack up) + Independent bool } // CustomProperties store additional data used to boot up the service, e.g. AWS credentials. diff --git a/internal/servicedeployer/kubernetes.go b/internal/servicedeployer/kubernetes.go index 786c0e00d7..3b967285bb 100644 --- a/internal/servicedeployer/kubernetes.go +++ b/internal/servicedeployer/kubernetes.go @@ -159,6 +159,7 @@ func (ksd KubernetesServiceDeployer) SetUp(ctx context.Context, svcInfo ServiceI } } + svcInfo.Agent.Independent = true svcInfo.Name = kind.ControlPlaneContainerName svcInfo.Hostname = kind.ControlPlaneContainerName // kind-control-plane is the name of the kind host where Pod is running since we use hostNetwork setting diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index 1c5a0813db..046eb601d6 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -340,6 +340,8 @@ func (r *runner) createServiceInfo() (servicedeployer.ServiceInfo, error) { svcInfo.OutputDir = outputDir } + svcInfo.Agent.Independent = false + return svcInfo, nil } @@ -935,8 +937,7 @@ func (r *runner) prepareScenario(ctx context.Context, config *testConfig, svcInf 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" - if !r.options.RunIndependentElasticAgent && !createdNewAgent { + if !r.options.RunIndependentElasticAgent && !svcInfo.Agent.Independent { return nil } logger.Debug("removing agent...")