Skip to content

Support OCI distribution spec error response body message field in err response within content.Writer #8969

Description

@kattmang

What is the problem you're trying to solve

(I'm an engineer for AWS ECR)

Currently, buildkit uses containerd's exporter for pushing images/remote caches to registries. An OCI-compliant registry will generally respond using the error response body format defined in the OCI distribution spec for 4xx responses:

    {
        "errors": [
            {
                "code": "<error identifier, see below>",
                "message": "<message describing condition>",
                "detail": "<unstructured>"
            },
            ...
        ]
    }

For example, when looking into a customer issue, I was able to intercept a 405 response from ECR to containerd for PUT /manifest:

{
	"errors": [{
		"code": "UNSUPPORTED",
		"message": "Invalid parameter at 'ImageManifest' failed to satisfy constraint: 'Image has to have at least 1 layer'"
	}]
}

but the ultimate error message from buildkit emits as:

ERROR: failed to solve: error writing manifest blob: failed commit on ref "sha256:55612c1681728655e4b91b3cf2a1752ab6e03e35cd5f6dd866f369a3d3a9a288": unexpected status from PUT request to https://<redacted>.dkr.ecr.us-east-1.amazonaws.com/v2/buildkittest/manifests/cache: 405 Method Not Allowed

The call to containerd from buildkit happens here.

Describe the solution you'd like

I believe a good improvement here would be to extend the remote docker push error handling code, especially in Commit (AFAICT) to look at the body of ErrUnexpectedStatus and attempt to marshall the body to the OCI error json format defined in the distribution spec. If so, embed the code and message from the json response into the err response upstream to itself (all the way up to writeBlob).

This would allow users of containerd, buildkit and docker to receive better error messages on failed pushes to OCI registries.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions