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

containerd integration: Passing a build context via tarball to the /build endpoint is broken #47717

Open
vvoland opened this issue Apr 15, 2024 · 0 comments
Labels
area/api area/builder/buildkit Issues affecting buildkit area/builder containerd-integration Issues and PRs related to containerd integration kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.

Comments

@vvoland
Copy link
Contributor

vvoland commented Apr 15, 2024

Description

Building via the /build endpoint with Version=BuilderBuildkit fails with:

failed to read downloaded context: failed to load cache key: invalid response status 403

When passing a build context via a tar without a build session.

It works with graphdrivers, because the mobyworker makes use of the passed http.RoundTripper:


func newGraphDriverController(ctx context.Context, rt http.RoundTripper, opt Opt) (*control.Controller, error) {

which is used to respond to a fake url echoing the passed build context:

url, cancel := b.reqBodyHandler.newRequest(rc)

With the containerd integration, the ContainerdWorker doesn't use this RoundTripper so it isn't able to access the build context.

Reproduce

package main

import (
	"context"
	"io"
	"os"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
)

func main() {
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		panic(err)
	}

	rd, err := os.Open("context.tar")
	if err != nil {
		panic(err)
	}
	defer rd.Close()

	imageBuildResponse, err := cli.ImageBuild(context.Background(), rd, types.ImageBuildOptions{
		Version: types.BuilderBuildKit, // without this, classic builder is used
		Tags:    []string{"myimage:latest"},
	})
	if err != nil {
		panic(err)
	}
	defer imageBuildResponse.Body.Close()

	_, err = io.Copy(os.Stdout, imageBuildResponse.Body)
	if err != nil {
		panic(err)
	}
}

context.tar.zip
(zipping a tar, because github doesn't allow uploading tars 🙈)

Expected behavior

No response

docker version

Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:14:46 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.30.0 (145546)
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:02 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

N/A

Additional Info

No response

@vvoland vvoland added area/api area/builder kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. area/builder/buildkit Issues affecting buildkit containerd-integration Issues and PRs related to containerd integration labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/builder/buildkit Issues affecting buildkit area/builder containerd-integration Issues and PRs related to containerd integration kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Projects
None yet
Development

No branches or pull requests

1 participant