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

400 Bad request when building images with registry cache to ECR #1118

Closed
angonz opened this issue Sep 3, 2024 · 3 comments
Closed

400 Bad request when building images with registry cache to ECR #1118

angonz opened this issue Sep 3, 2024 · 3 comments

Comments

@angonz
Copy link
Contributor

angonz commented Sep 3, 2024

Bug description
When building images with registry cache, and when the cache is in AWS' ECR, building results in 400 Bad request error.

------
 > importing cache manifest from 2xxxxxxx4.dkr.ecr.us-east-1.amazonaws.com/myrepo/openedx:202409032122-cache:
------
------
 > exporting cache to registry:
------
error: failed to solve: rpc error: code = Unknown desc = error writing manifest blob: failed commit on ref "sha256:dbddfa9dc32dd219457de9c9b1534f667024da6e36e5a085f7f52540fc9ef9af": unexpected status from PUT request to https://2xxxxxxx4.dkr.ecr.us-east-1.amazonaws.com/v2/myrepo/openedx/manifests/202409032122-cache: 400 Bad Request
Error: Command failed with status 1: docker buildx build --tag=2xxxxxxx4.dkr.ecr.us-east-1.amazonaws.com/myrepo/openedx:202409032122 --output=type=docker --builder=container --cache-from=type=registry,ref=2xxxxxxx4.dkr.ecr.us-east-1.amazonaws.com/myrepo/openedx:202409032122-cache --cache-to=type=registry,mode=max,ref=2xxxxxxx4.dkr.ecr.us-east-1.amazonaws.com/myrepo/openedx:202409032122-cache /home/myuser/mytutorroot/env/build/openedx
Error building openedx

How to reproduce

  • Create an ECR registry in AWS
  • Declare the registry url in the DOCKER_REGISTRY variable
  • Log in to ECR
  • Run tutor images build openedx --cache-to-registry

Environment

Tested with Tutor 17.0.6

Additional context

As per this document, adding image-manifest=true context to the docker buildx command fixed the issue.

The new context key introduced in Buildkit 0.12 here is image-manifest. Setting this key’s value to true lets you now store an OCI-compatible version of a remote cache in the registry.

If it doesn't break the official repos (which I cannot test), I would like to add this key to the image build args.

@angonz
Copy link
Contributor Author

angonz commented Sep 4, 2024

I have just hardcoded the image-manifest=true to the build command in PR #1119. Please check if it doesn't impact negatively in the official, public Docker registry.
Another option would be to do it under another option, like --cache-to-registry-oci or similar.

@DawoudSheraz DawoudSheraz closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tutor project management Oct 17, 2024
@DawoudSheraz DawoudSheraz moved this from Done to Won't fix in Tutor project management Oct 17, 2024
fghaas added a commit to fghaas/tutor that referenced this issue Nov 21, 2024
Without this change, when building images with --cache-to-registry,
BuildKit uses a proprietary cache artifact format, which breaks
when using third-party registries such as Harbor or ECR.

By adding the image-manifest=true option, BuildKit uses an
OCI-compliant cache artifact format that should be compatible with all
registries.

See goharbor/harbor#18941 and
moby/buildkit#2251 for background
information.

Co-authored-by: Andrés González <[email protected]>

Fixes overhangio#1118.
fghaas added a commit to fghaas/tutor that referenced this issue Nov 21, 2024
Without this change, when building images with --cache-to-registry,
BuildKit uses a proprietary cache artifact format, which breaks
when using third-party registries such as Harbor or ECR.

By adding the image-manifest=true option, BuildKit uses an
OCI-compliant cache artifact format that should be compatible with all
registries. This option requires BuildKit 0.12 or later (check with
"docker buildx ls").

See goharbor/harbor#18941 and
moby/buildkit#2251 for background
information.

Co-authored-by: Andrés González <[email protected]>

Fixes overhangio#1118.
regisb pushed a commit that referenced this issue Nov 21, 2024
Without this change, when building images with --cache-to-registry,
BuildKit uses a proprietary cache artifact format, which breaks
when using third-party registries such as Harbor or ECR.

By adding the image-manifest=true option, BuildKit uses an
OCI-compliant cache artifact format that should be compatible with all
registries. This option requires BuildKit 0.12 or later (check with
"docker buildx ls").

See goharbor/harbor#18941 and
moby/buildkit#2251 for background
information.

Co-authored-by: Andrés González <[email protected]>

Fixes #1118.
@fghaas
Copy link
Contributor

fghaas commented Nov 21, 2024

@regisb Just a suggestion to alleviate potential confusion: with #1161 merged, you may want to re-open this issue and then re-close it with a status other than "not planned". :)

@regisb regisb reopened this Nov 21, 2024
@github-project-automation github-project-automation bot moved this from Won't fix to Backlog in Tutor project management Nov 21, 2024
@regisb
Copy link
Contributor

regisb commented Nov 21, 2024

Closed by #1161

@regisb regisb closed this as completed Nov 21, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Tutor project management Nov 21, 2024
Ian2012 pushed a commit to eduNEXT/tutor that referenced this issue Nov 21, 2024
Without this change, when building images with --cache-to-registry,
BuildKit uses a proprietary cache artifact format, which breaks
when using third-party registries such as Harbor or ECR.

By adding the image-manifest=true option, BuildKit uses an
OCI-compliant cache artifact format that should be compatible with all
registries. This option requires BuildKit 0.12 or later (check with
"docker buildx ls").

See goharbor/harbor#18941 and
moby/buildkit#2251 for background
information.

Co-authored-by: Andrés González <[email protected]>

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

Successfully merging a pull request may close this issue.

4 participants