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

Retry each crane command on 429 after a sleep #10

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

yosifkit
Copy link
Member

Also, move the crane commands generator to a .jq file instead of embedded in the Jenkinsfile for easier debugging

Copy link
Collaborator

@whalelines whalelines left a comment

Choose a reason for hiding this comment

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

This is a great idea. Just a couple questions…

Jenkinsfile.deploy Outdated Show resolved Hide resolved
@@ -89,7 +76,25 @@ node('multiarch-' + env.BASHBREW_ARCH) { ansiColor('xterm') {
sh """#!/usr/bin/env bash
set -Eeuo pipefail

${ shell }
commands=( ${ shell } )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this split the expanded Groovy variable shell on whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. That's why it does crane_deploy_commands | @sh to create it. The function will return a stream of crane commands and then each one will be shell quoted to be a single shell string.

crane_deploy_commands
crane copy ...
crane copy ...
-> @sh
'crane copy ...'
'crane copy ...'

Copy link
Member

Choose a reason for hiding this comment

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

And to be clear, this won't be shell doing expansion/splitting, but rather the Groovy will embed the generated and appropriately quoted shell code directly in the string it passes to the shell for invocation, so the end result of what the shell actually executes will be literally something like:

commands=( 'crane copy ...'
'crane copy ...' )

Jenkinsfile.deploy Outdated Show resolved Hide resolved
Jenkinsfile.deploy Outdated Show resolved Hide resolved
Copy link
Collaborator

@whalelines whalelines left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Just one minor nit and a few non-action comments 👍

Jenkinsfile.deploy Outdated Show resolved Hide resolved
Jenkinsfile.deploy Outdated Show resolved Hide resolved
# input: list of build objects i.e., builds.json
# output: stream of crane copy command strings
def crane_deploy_commands:
reduce (.[] | select(.build.resolved and .build.arch == env.BASHBREW_ARCH)) as $i ({};
Copy link
Member

Choose a reason for hiding this comment

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

In the future, it might be worth splitting this select out to be the responsibility of the caller, but I don't think we should do that here 👀

(Especially since the use cases I have in mind aren't well formed yet, so it's not worth doing anything concrete yet)

tries=3
while ! output="$( { $c; } |& tee /dev/stderr )"; then
# check to see if we hit the docker hub rate limit
if grep -q 'TOOMANYREQUESTS' <<<"$output"; then
Copy link
Member

Choose a reason for hiding this comment

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

Is TOOMANYREQUESTS something crane outputs, or something that just happens to be in the error text from Docker Hub right now (and thus might change in the future)?

I don't think this is worth doing much about (ie, this is fine as-is because the failure mode would be that we just ... don't retry and thus the problem becomes obvious), but something to consider in the future.

move the crane commands generator to a jq file instead of embedded in the Jenkinsfile for easier debugging
@tianon
Copy link
Member

tianon commented Dec 15, 2023

Fire in the hole!

@tianon tianon merged commit 88f2840 into docker-library:main Dec 15, 2023
1 check passed
@tianon tianon deleted the deploy-retries branch December 15, 2023 21:46
tianon added a commit that referenced this pull request Dec 15, 2023
@tianon
Copy link
Member

tianon commented Dec 15, 2023

We're seeing some weirdness in how this actually runs, and it's probably thanks to https://www.docker.com/increase-rate-limits/ (these jobs are actually hitting the "normal" 429 that only resets every 6 hours and for the user on that host only gives 200 / 6 hours and our other usage on that system has been mitigating that in other ways until now 🙃).

Gonna look at patching our crane build now to see if we can have an "easy" bandaid.

@tianon
Copy link
Member

tianon commented Dec 18, 2023

With a bit more hacking, this is now doing much better (the bandaid was extremely successful). 👍

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.

3 participants