-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
There was a problem hiding this 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…
@@ -89,7 +76,25 @@ node('multiarch-' + env.BASHBREW_ARCH) { ansiColor('xterm') { | |||
sh """#!/usr/bin/env bash | |||
set -Eeuo pipefail | |||
|
|||
${ shell } | |||
commands=( ${ shell } ) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ...'
There was a problem hiding this comment.
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 ...' )
fc5d239
to
715f2ed
Compare
715f2ed
to
d53f6f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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 👍
# 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 ({}; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
d53f6f2
to
8a4c026
Compare
Fire in the hole! |
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 |
With a bit more hacking, this is now doing much better (the bandaid was extremely successful). 👍 |
Also, move the crane commands generator to a
.jq
file instead of embedded in the Jenkinsfile for easier debugging