Skip to content
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

Artifact download doesn’t use most recent artifact when names collide #803

Open
jmendiara opened this issue Jul 26, 2018 · 6 comments · Fixed by #1268
Open

Artifact download doesn’t use most recent artifact when names collide #803

jmendiara opened this issue Jul 26, 2018 · 6 comments · Fixed by #1268
Labels
artifacts Relating to artifact upload/download bug

Comments

@jmendiara
Copy link

Take the following scenario

$ ls logs
logfile.txt
steps: 
  - command: exit 0
    artifact_paths:
      - "logs/*"
      - "logs/*"

logfile.txt, is uploaded twice by the agent and It's stored twice in the backend:
Downloading with buildkite-agent artifact download logs/logfile.txt logs/ says

Failed to download artifacts: GET https://agent.buildkite.com/v3/builds/xxx/artifacts/search?query=logs%2Flogfile.txtl: 
 400 Multiple artifacts were found for query: `logs/logfile.txt`. Try scoping by the job ID or name.

Is this the correct behaviour? Should't filter the agent dup files when expanding paths?

Also, i think (not sure) executing this in the command for the same job may result in 3 files with the same sha

buildkite-agent artifact upload "logs/logfile.txt"

Should backend dedup files with the same sha for the same job?

@lox
Copy link
Contributor

lox commented Jul 26, 2018

We'll investigate!

@lox lox added the bug label Jul 26, 2018
@donparapidos
Copy link

donparapidos commented Oct 6, 2019

Hello,

Hows with investigation on this one ? I am often facing issue as described:

buildkite-agent artifact upload application-$BUILDKITE_BUILD_NUMBER.nomad

in the next step I use artifact plugin to download application-$BUILDKITE_BUILD_NUMBER.nomad and get:


Downloading artifacts | 0s
-- | --
  | 2019-10-06 15:22:43 INFO   Searching for artifacts: "application-68.nomad"
  | 2019-10-06 15:22:43 FATAL  Failed to download artifacts: GET https://agent.buildkite.com/v3/builds/xxxxxxx/artifacts/search?query=application-68.nomad: 400 Multiple artifacts were found for query: `application-68.nomad`. Try scoping by the job ID or name.

@O1ahmad
Copy link

O1ahmad commented Aug 14, 2020

+1 Also experiencing the same in which a generated pipeline uploads multiple instances of an artifact (uploaded with identical names/paths) resulting in subsequent downloads of this artifact name during downstream steps to fail on a (400 Multiple artifacts were found for query) error:

2020-08-14 17:31:10 FATAL  Failed to download artifacts: GET https://agent.buildkite.com/v3/builds/562798f2-c9ca-4cea-9449-4c8485bf1d77/artifacts/search?query=DOCKER_DEPLOY_ENV: 400 Multiple artifacts were found for query: `DOCKER_DEPLOY_ENV`. Try scoping by the job ID or name.
--
  | 🚨 Error: The command exited with status 1

@pda
Copy link
Member

pda commented Aug 17, 2020

#1268 fixes the case where a single buildkite-agent artifact upload would upload the same file twice if it's matched by multiple paths/globs. That includes the array version of artifact_paths in YAML pipelines.

I suspect some people in this issue are experiencing the issue due to separate uploads using the same path, perhaps from different steps within the same build. In those cases, I'd suggest ensuring a path is only uploaded once in the build. You might want to incorporate BUILDKITE_JOB_ID (a server-generated UUID) in the filename? Admittedly that will make it harder to find afterwards.

@pda pda closed this as completed in #1268 Aug 17, 2020
@lk86
Copy link

lk86 commented Aug 17, 2020

@0x0i and I discovered this issue largely because the buildkite-agent artifact download does not work according to the doumentation, and #1268 does not resolve this issue. Quote from the documentation:

"The buildkite-agent artifact command will find the most recent file uploaded with a matching filename, no matter which build step uploaded it. If you want to target an artifact from a particular build step use the --step argument."

As anyone in this thread has experienced, it does not download the most recent file, it only downloads unique files uploaded by a pipeline. If this is not the intended behavior we can certainly work around the --step solution but the documentation remains incredibly misleading.

@pda
Copy link
Member

pda commented Aug 19, 2020

Oh interesting — I hadn't realised the docs said that. I'll reopen the issue.

@pda pda reopened this Aug 19, 2020
@keithduncan keithduncan added the artifacts Relating to artifact upload/download label Jul 26, 2021
@keithduncan keithduncan changed the title Duplicated artifact upload Artifact download doesn’t use most recent artifact when names collide Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
artifacts Relating to artifact upload/download bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants