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 (and shasum) only search for finished uploads. #1584

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

pda
Copy link
Member

@pda pda commented Mar 18, 2022

The Artifact Search API endpoint supports filtering the search to finished artifacts, so that incomplete uploads are not included.

buildkite-agent artifact download and buildkite-agent artifact shasum probably want to apply that filter, otherwise they're likely to get stuck trying to download artifacts that don't exist.

  • more testing and/or local validation.
  • sanity-check the decision to not attempt downloading unfinished artifacts.

@pda pda requested a review from waferbaby March 18, 2022 00:49
Copy link

@waferbaby waferbaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yesss, this looks like exactly what we need!

@pda
Copy link
Member Author

pda commented Mar 18, 2022

Given this command:

buildkite-agent artifact download --debug hello.txt .

Before this PR, for an artifact in new state (not finished), it was downloaded:
(in this case the download was successful because I reverted an uploaded artifact back to new state)

2022-03-18 11:35:32 INFO   Searching for artifacts: "hello.txt"
2022-03-18 11:35:32 DEBUG  GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt
2022-03-18 11:35:32 DEBUG  ↳ GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt proto=HTTP/1.1 status=200 Δ=61.300692ms
2022-03-18 11:35:32 INFO   Found 1 artifacts. Starting to download to: /redacted/local/dir
2022-03-18 11:35:32 DEBUG  Downloading http://redacted/hello.txt?redacted to /redacted/local/dir/hello.txt
2022-03-18 11:35:32 INFO   Successfully downloaded "hello.txt" 6 bytes

After this PR for that same new (unfinished) artifact:
Note the /artifacts/search?query=hello.txt&state=finished API call now passes state parameter.
And the unfinished artifact is not found.

2022-03-18 11:35:28 INFO   Searching for artifacts: "hello.txt"
2022-03-18 11:35:28 DEBUG  GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt&state=finished
2022-03-18 11:35:28 DEBUG  ↳ GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt&state=finished proto=HTTP/1.1 status=200 Δ=88.67795ms
2022-03-18 11:35:28 FATAL  Failed to download artifacts: No artifacts found for downloading

After this PR, once the artifact is finished, just to make sure it still works:
Note the state=finished is still in the API call.
And again, the download succeeds because this was a successful upload that I reverted to new state.

2022-03-18 11:38:56 INFO   Searching for artifacts: "hello.txt"
2022-03-18 11:38:56 DEBUG  GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt&state=finished
2022-03-18 11:38:56 DEBUG  ↳ GET http://agent.buildkite.localhost/v3/builds/8faced79-94fc-4e61-bc99-49162bf0b275/artifacts/search?query=hello.txt&state=finished proto=HTTP/1.1 status=200 Δ=66.417817ms
2022-03-18 11:38:56 INFO   Found 1 artifacts. Starting to download to: /Users/pda/bk/test-repo
2022-03-18 11:38:56 DEBUG  Downloading http://redacted/hello.txt?redacted to /Users/pda/bk/test-repo/hello.txt
2022-03-18 11:38:56 INFO   Successfully downloaded "hello.txt" 6 bytes

@pda
Copy link
Member Author

pda commented Mar 18, 2022

Also a quick buildkite-agent artifact shasum test, because this PR also changes that to only look at finished uploads:

For an unfinished artifact:

pda@paulbookpro ~/bk/test-repo $ ~/bk/agent/buildkite-agent artifact shasum hello.txt
2022-03-18 11:44:08 INFO   Searching for artifacts: "hello.txt"
2022-03-18 11:44:08 FATAL  No artifacts found for downloading

For a finished artifact:

pda@paulbookpro ~/bk/test-repo $ ~/bk/agent/buildkite-agent artifact shasum hello.txt
2022-03-18 11:43:58 INFO   Searching for artifacts: "hello.txt"
f572d396fae9206628714fb2ce00f72e94f2258f

@pda
Copy link
Member Author

pda commented Mar 18, 2022

Here's a previous report that @pzeballos pointed out which validates that this change should be good: #1511

@pda pda merged commit dfa40f4 into main Mar 18, 2022
@pda pda deleted the artifact-download-only-finished-artifacts branch March 18, 2022 03:59
@pda
Copy link
Member Author

pda commented Jul 27, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants