-
Notifications
You must be signed in to change notification settings - Fork 482
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
GCP Cloud Build 1 hour timeout - failed to fetch oauth token: unexpected status: 401 Unauthorized #1205
Comments
This ZcashFoundation PR seems to fix the same issue in Github CI. I wonder if there is a way to set this in GCP Cloud Build?
Docs on this state:
I time-boxed a dive into this at an hour, but didn't learn much (to many unknowns about how Docker runs inside of GCP). |
+1 @dougdonohoe seeing this issue as well. Workaround for me was to create a service account json key that I passed in base64 through env var and then performed a docker login with it prior to the buildx command. This is not ideal for security but working. Posting here to help out the next person to encounter this. Here is implementation for anyone stuck and finding this through google:
|
Thanks @parkerroan - out of curiosity, what permissions did you give the service account that key belongs to? Also, this sounds like a good use for Google Secret Manager. My article, noted below, has an example of using it for This also might be of interest: I just published a medium post on how to use Also mentioned in that article is my docker-buildx.sh script which I use to break the |
Hey @dougdonohoe I just tumble in this very issue, did you find a way to solve this? is there any way to extend the token provided by Google? |
@Davidnet I haven't explored @parkerroan's solution yet. What we do is use this script to break the build into two parts, which has provided some success: https://github.com/dougdonohoe/multi-arch-docker/blob/main/docker-buildx.sh |
Perfect, @dougdonohoe I made it work by specifying the image in the image field instead of doing Hope this can bring visibility to this "options": {
"diskSizeGb": "200",
"machineType": "N1_HIGHCPU_8",
"logging": "CLOUD_LOGGING_ONLY"
},
"timeout": "18000s",
"images": [
"us-central1-docker.pkg.dev/project/repo/image_name:image_tag"
] |
Background
At my company, I have a new Apple M1 MacBook Pro. Most of our build infrastructure is all
amd64
images, which run very slow and flakey on thearm64
M1 laptop. I've been working on building multi-architecture images usingdocker buildx
and have run into a problem automating these builds in GCP Cloud Build and publishing to/from GCP Artifact Registry.Our regular
amd64
image build normally takes about 15 minutes. Adding thearm64
platform shoots the build time to an hour and a half. While this build works locally on my laptop, it times out on GCP Cloud Build if it is longer than an hour.Problem Synopsis
Running a cloud build that does
docker buildx build --platform linux/amd64,linux/arm64 --push
times out when it attempts to push items to Artifact Registry:Workaround
I discovered the workaround is to break the build into three steps:
--push
or--cache-to
My guess is that stopping the builder forces oauth tokens to be re-fetched in step 3.
My docker-buildx.sh script is what I ended up using to do this.
Details
A full explanation with reproducible example can be found at my build-timeout repo.
Next Steps
It isn't clear where this problem lies (e.g., in
buildx
or with Google Cloud Build/Artifact Registry or some combination). I'm also going to raise this issue with Google through my company as a support ticket.I haven't dug into the internals of
buildx
(and how it interacts with things like GCP Artifact Registry) or how Docker works in an environment like GCP Cloud Build and was hoping abuildx
core contributor might have an idea of where to look or what might be happening. The workaround of stopping the builder is an interesting clue.Possible solution?
Not sure if this will work, but maybe
buildx
can request the tokens on demand, rather than at startup?The text was updated successfully, but these errors were encountered: