Skip to content

Commit

Permalink
systemtest: don't pull elastic-agent image (#7162) (#7174)
Browse files Browse the repository at this point in the history
I think at some point in the past there was a separate
image for fleet-server, and we separately pulled the
elastic-agent image. Fleet-server now (at least) runs
under elastic-agent, so we can use the exact same image
and avoid a network trip.

(cherry picked from commit 8010904)

Co-authored-by: Andrew Wilkins <[email protected]>
  • Loading branch information
mergify[bot] and axw authored Feb 2, 2022
1 parent 7cdcce2 commit 088c1e7
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions systemtest/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,9 @@ func NewUnstartedElasticAgentContainer() (*ElasticAgentContainer, error) {
systemtestDir := filepath.Dir(filename)
hostCACertPath := filepath.Join(systemtestDir, "../testing/docker/fleet-server/ca.pem")

// Use the same stack version as used for fleet-server.
// Use the same elastic-agent image as used for fleet-server.
agentImageVersion := fleetServerContainer.Image[strings.LastIndex(fleetServerContainer.Image, ":")+1:]
agentImage := "docker.elastic.co/beats/elastic-agent:" + agentImageVersion
if err := pullDockerImage(context.Background(), docker, agentImage); err != nil {
return nil, err
}
agentImageDetails, _, err := docker.ImageInspectWithRaw(context.Background(), agentImage)
if err != nil {
return nil, err
Expand All @@ -356,10 +353,9 @@ func NewUnstartedElasticAgentContainer() (*ElasticAgentContainer, error) {
SkipReaper: true, // we use our own reaping logic
}
return &ElasticAgentContainer{
request: req,
exited: make(chan struct{}),
Reap: true,
StackVersion: agentImageVersion,
request: req,
exited: make(chan struct{}),
Reap: true,
}, nil
}

Expand All @@ -375,10 +371,6 @@ type ElasticAgentContainer struct {
// from being stoped and removed.
Reap bool

// StackVersion holds the stack version of the container image,
// e.g. 8.0.0-SNAPSHOT.
StackVersion string

// ExposedPorts holds an optional list of ports to expose to the host.
ExposedPorts []string

Expand Down Expand Up @@ -570,16 +562,6 @@ func (c *ElasticAgentContainer) Exec(ctx context.Context, cmd ...string) (stdout
return stdoutBuf.Bytes(), stderrBuf.Bytes(), nil
}

func pullDockerImage(ctx context.Context, docker *client.Client, imageRef string) error {
rc, err := docker.ImagePull(context.Background(), imageRef, types.ImagePullOptions{})
if err != nil {
return err
}
defer rc.Close()
_, err = io.Copy(ioutil.Discard, rc)
return err
}

func matchFleetServerAPIStatusHealthy(r io.Reader) bool {
var status struct {
Name string `json:"name"`
Expand Down

0 comments on commit 088c1e7

Please sign in to comment.