Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

unable to reference sats.Hostname when checking standalone agent status in fleet #984

@adam-stokes

Description

@adam-stokes

When we are calling startAgent prior to verifying if the agent is in an online status, something is happening where sats.Hostname is not defined which causes the checking of the agent id to fail. I can't figure out what's going on because all debugging attempts seem to get swallowed from the output when calling:

func (sats *StandAloneTestSuite) theAgentIsListedInFleetWithStatus(desiredStatus string) error {
	return theAgentIsListedInFleetWithStatus(desiredStatus, sats.Hostname)
}

The output from the issue:

Feature: Stand-alone Agent
  Scenarios for a standalone mode Elastic Agent in Fleet, where an Elasticseach
  and a Kibana instances are already provisioned, so that the Agent is able to communicate
  with them
TRAC[0005] Before Fleet scenario
TRAC[0005] Executing request                             escapedURL="http://localhost:5601/api/fleet/agent_policies" method=GET
TRAC[0006] Fleet policies retrieved                      count=2
TRAC[0006] Deploying an agent to Fleet
TRAC[0006] Adding services to compose                    profile=fleet services="[elastic-agent]"
TRAC[0006] Compose file found at workdir                 composeFilePath=/Users/adam/.op/compose/profiles/fleet/docker-compose.yml type=profiles
TRAC[0006] Compose file found at workdir                 composeFilePath=/Users/adam/.op/compose/services/elastic-agent/docker-compose.yml type=services
fleet_elasticsearch_1 is up-to-date
fleet_package-registry_1 is up-to-date
fleet_kibana_1 is up-to-date
fleet_elastic-agent_1 is up-to-date
DEBU[0006] Docker compose executed.                      cmd="[up -d]" composeFilePaths="[/Users/adam/.op/compose/profiles/fleet/docker-compose.yml /Users/adam/.op/compose/services/elastic-agent/docker-compose.yml]" env="map[elasticAgentContainerName:fleet_elastic-agent_1 elasticAgentDockerImageSuffix: elasticAgentDockerNamespace:beats elasticAgentPlatform:linux/amd64 elasticAgentTag:8.0.0-SNAPSHOT fleetServerMode:1 stackVersion:8.0.0-SNAPSHOT]" profile=fleet
TRAC[0006] Updating state                                dir=/Users/adam/.op stateFile=/Users/adam/.op/fleet-profile.run
TRAC[0006] State updated                                 dir=/Users/adam/.op stateFile=/Users/adam/.op/fleet-profile.run
TRAC[0006] Retrieving container name from the Docker client  containerName=fleet_elastic-agent_1
TRAC[0006] Creating command to be executed in container  command="[cat /etc/hostname]" container=fleet_elastic-agent_1 detach=false tty=false
TRAC[0006] Command to be executed in container created   command="[cat /etc/hostname]" container=fleet_elastic-agent_1 detach=false tty=false
TRAC[0006] Command sucessfully executed in container     command="[cat /etc/hostname]" container=fleet_elastic-agent_1 detach=false tty=false
TRAC[0006] Output name has been sanitized                output=387465c79826
INFO[0006] Hostname retrieved from the Docker client     containerName=fleet_elastic-agent_1 hostname=387465c79826

  Scenario Outline: Deploying a <image> stand-alone agent with fleet server mode # features/stand_alone_agent.feature:55
TRAC[0006] Checking if agent is listed in Fleet as online
TRAC[0006] Retrieving agentID for
TRAC[0006] Executing request                             escapedURL="http://localhost:5601/api/fleet/agents?page=1&perPage=20&showInactive=false" method=GET
TRAC[0007] Retrieving agentID for
TRAC[0007] Executing request                             escapedURL="http://localhost:5601/api/fleet/agents?page=1&perPage=20&showInactive=false" method=GET
TRAC[0008] Retrieving agentID for
TRAC[0008] Executing request                             escapedURL="http://localhost:5601/api/fleet/agents?page=1&perPage=20&showInactive=false" method=GET

You can see that the hostname and container name are both found by adding debug statements to:

	// get container hostname once
	hostname, err := steps.GetContainerHostname(containerName)
	if err != nil {
		return err
	}

	sats.Image = image
	sats.Hostname = hostname
	sats.Cleanup = true

I can verify that those properties are being set. However, as soon as that next scenario is run it can no longer determine the hostname to gather the agent information from.

To reproduce:

cd e2e/_suites/fleet
OP_LOG_LEVEL=TRACE godog run -t 'run_fleet_server'

Is anyone else able to reproduce this or have seen anything like this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions