Skip to content

Docker builds failing with invalid tar header or EOF errors #11604

@cmacknz

Description

@cmacknz

Examples from Buildkite below which are both FIPS builds:

I have reproduced this locally on main on MacOS using DOCKER_VARIANTS=slim EXTERNAL=true SNAPSHOT=true PACKAGES=docker PLATFORMS=linux/arm64 mage package which gives me package_test.go:426: error reading file /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-slim-9.3.0-SNAPSHOT-linux-arm64.docker.tar.gz: archive/tar: invalid tar header.

I have also seen an EOF error:

❯ DOCKER_VARIANTS=slim EXTERNAL=true SNAPSHOT=true PACKAGES=docker PLATFORMS=linux/arm64 mage package
--- Package Elastic-Agent
Downloading from https://artifacts-snapshot.elastic.co/cloudbeat/9.3.0-20f62a8a/downloads/cloudbeat/cloudbeat-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/prodfiler/9.3.0-457b6adf/downloads/prodfiler/pf-elastic-symbolizer-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/prodfiler/9.3.0-457b6adf/downloads/prodfiler/pf-elastic-collector-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/prodfiler/9.3.0-457b6adf/downloads/prodfiler/pf-host-agent-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/apm-server/9.3.0-6d1a1b7b/downloads/apm-server/apm-server-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/fleet-server/9.3.0-cf7aa1c7/downloads/fleet-server/fleet-server-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/endpoint-dev/9.3.0-ca1e6b41/downloads/endpoint-dev/endpoint-security-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/beats/9.3.0-c080c72e/downloads/beats/agentbeat/agentbeat-9.3.0-SNAPSHOT-linux-arm64.tar.gz
Downloading from https://artifacts-snapshot.elastic.co/connectors/9.3.0-f726f49f/downloads/connectors/connectors-9.3.0-SNAPSHOT.zip
Done downloading connectors-9.3.0-SNAPSHOT.zip into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading pf-elastic-symbolizer-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading fleet-server-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading pf-elastic-collector-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading apm-server-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading pf-host-agent-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading endpoint-security-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading cloudbeat-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
Done downloading agentbeat-9.3.0-SNAPSHOT-linux-arm64.tar.gz into /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/archives/linux-arm64.tar.gz
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/pf-host-agent.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/apm-server.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/cloudbeat.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/endpoint-security.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/fleet-server.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/pf-elastic-collector.spec.yml does not exist, reverting to local specfile
>> File /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-drop/linux-arm64.tar.gz/pf-elastic-symbolizer.spec.yml does not exist, reverting to local specfile
>> BuildFleetCfg _meta/elastic-agent.fleet.yml to internal/pkg/agent/application/configuration_embed.go
>> BuildPGP from GPG-KEY-elasticsearch to internal/pkg/release/pgp.go
>> Building elastic-agent.yml for linux/amd64
>> Building elastic-agent.reference.yml for linux/amd64
>> Building elastic-agent.docker.yml for linux/amd64
--- CrossBuild Elastic-Agent
>> golangCrossBuild: Building for linux/arm64
>> Building using: cmd='build/mage-linux-arm64 golangCrossBuild', env=[GOARCH=arm64, GOARM=, GOOS=linux, GOTOOLCHAIN=local, PLATFORM_ID=linux-arm64]
--- Package artifact
>> package: Building linux-arm64
>> package: Building elastic-agent type=docker for platform=linux/arm64 fips=false
[+] Building 33.5s (22/22) FINISHED                                                          docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                         0.0s
 => => transferring dockerfile: 6.92kB                                                                       0.0s
 => WARN: FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/arm64"  0.0s
 => WARN: FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/arm64"  0.0s
 => [internal] load metadata for docker.io/redhat/ubi9-minimal:latest                                        0.3s
 => [internal] load metadata for cgr.dev/chainguard/wolfi-base:latest                                        0.5s
 => [internal] load .dockerignore                                                                            0.0s
 => => transferring context: 2B                                                                              0.0s
 => [stage-1  1/11] FROM docker.io/redhat/ubi9-minimal:latest@sha256:6fc28bcb6776e387d7a35a2056d9d2b985dc4e  0.0s
 => => resolve docker.io/redhat/ubi9-minimal:latest@sha256:6fc28bcb6776e387d7a35a2056d9d2b985dc4e26031e98a2  0.0s
 => [internal] load build context                                                                            9.8s
 => => transferring context: 1.60GB                                                                          9.7s
 => [home 1/5] FROM cgr.dev/chainguard/wolfi-base:latest@sha256:42012fa027adc864efbb7cf68d9fc575ea45fe1b9fb  0.0s
 => => resolve cgr.dev/chainguard/wolfi-base:latest@sha256:42012fa027adc864efbb7cf68d9fc575ea45fe1b9fb0d166  0.0s
 => CACHED [home 2/5] RUN for iter in {1..10}; do         apk fix &&         apk add --no-cache shadow libc  0.0s
 => [home 3/5] COPY beat /usr/share/elastic-agent                                                            1.3s
 => [home 4/5] RUN true &&     chmod 0777 /usr/share/elastic-agent &&     mkdir -p /usr/share/elastic-agent  1.8s
 => [home 5/5] RUN setcap =p /usr/share/elastic-agent/data/elastic-agent-80a396/elastic-agent && true        0.4s
 => CACHED [stage-1  2/11] RUN for iter in {1..10}; do           microdnf update -y &&           microdnf i  0.0s
 => CACHED [stage-1  3/11] RUN set -e ;   TINI_BIN="";   TINI_SHA256="";   TINI_VERSION="v0.19.0";   case "  0.0s
 => CACHED [stage-1  4/11] COPY docker-entrypoint /usr/local/bin/docker-entrypoint                           0.0s
 => CACHED [stage-1  5/11] RUN groupadd --gid 1000 elastic-agent &&     useradd -M --uid 1000 --gid 1000 --  0.0s
 => [stage-1  6/11] COPY --chown=elastic-agent:elastic-agent --from=home /usr/share/elastic-agent /usr/shar  0.7s
 => [stage-1  7/11] RUN chmod 0777 /usr/share/elastic-agent &&     usermod -d /usr/share/elastic-agent elas  0.3s
 => [stage-1  8/11] RUN mkdir /licenses                                                                      0.1s
 => [stage-1  9/11] COPY --from=home /usr/share/elastic-agent/LICENSE.txt /licenses                          0.0s
 => [stage-1 10/11] COPY --from=home /usr/share/elastic-agent/NOTICE.txt /licenses                           0.0s
 => [stage-1 11/11] WORKDIR /usr/share/elastic-agent                                                         0.0s
 => exporting to image                                                                                      17.7s
 => => exporting layers                                                                                     15.5s
 => => exporting manifest sha256:d50411ff7a9000fa65e7a1634af2db2d6b3455ecfbde591d868c155f6162bbdb            0.0s
 => => exporting config sha256:6bd4fbc9ea3804d3ea075386cf41663a20792c43cc8a373f3f59c5391717467d              0.0s
 => => exporting attestation manifest sha256:2ef9a3904c6f74a77f41cb82588d8d8892c6d5058ca1d178c195b50d54851c  0.0s
 => => exporting manifest list sha256:e2c9b493a0a5003014177a3de8b95a1dd5fe582d2590623358d8bd3d1e40fef5       0.0s
 => => naming to docker.elastic.co/elastic-agent/elastic-agent-slim:9.3.0-SNAPSHOT                           0.0s
 => => unpacking to docker.elastic.co/elastic-agent/elastic-agent-slim:9.3.0-SNAPSHOT                        2.2s

 2 warnings found (use docker --debug to expand):
 - FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/arm64" (line 44)
 - FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/arm64" (line 5)
--- TestPackages, the generated packages (i.e. file modes, owners, groups).
--- TestPackages
>> Testing package contents
package ran for 1m19.166894541s
Error: error running package_test.go: running "go test /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/dev-tools/packaging/testing/package_test.go -root-owner -files /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/* --source-root /Users/cmackenzie/go/src/github.com/elastic/elastic-agent" failed with exit code 1, stdout: --- FAIL: TestDocker (0.94s)
    --- FAIL: TestDocker/elastic-agent-slim-9.3.0-SNAPSHOT-linux-arm64.docker.tar.gz (0.94s)
        package_test.go:126: /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-slim-9.3.0-SNAPSHOT-linux-arm64.docker.tar.gz
        package_test.go:426: error reading file /Users/cmackenzie/go/src/github.com/elastic/elastic-agent/build/distributions/elastic-agent-slim-9.3.0-SNAPSHOT-linux-arm64.docker.tar.gz: unexpected EOF
FAIL
FAIL    com

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions