mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to v0.19.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
6
vendor/github.com/moby/buildkit/util/testutil/integration/frombinary.go
generated
vendored
6
vendor/github.com/moby/buildkit/util/testutil/integration/frombinary.go
generated
vendored
@ -5,9 +5,9 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/content/local"
|
||||
"github.com/containerd/containerd/images/archive"
|
||||
"github.com/containerd/containerd/v2/core/content"
|
||||
"github.com/containerd/containerd/v2/core/images/archive"
|
||||
"github.com/containerd/containerd/v2/plugins/content/local"
|
||||
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
|
7
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
7
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
@ -17,8 +17,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/remotes/docker"
|
||||
"github.com/containerd/containerd/v2/core/content"
|
||||
"github.com/containerd/containerd/v2/core/remotes/docker"
|
||||
"github.com/gofrs/flock"
|
||||
"github.com/moby/buildkit/util/appcontext"
|
||||
"github.com/moby/buildkit/util/contentutil"
|
||||
@ -39,6 +39,7 @@ type Backend interface {
|
||||
Address() string
|
||||
DockerAddress() string
|
||||
ContainerdAddress() string
|
||||
DebugAddress() string
|
||||
|
||||
Rootless() bool
|
||||
NetNSDetached() bool
|
||||
@ -200,7 +201,7 @@ func Run(t *testing.T, testCases []Test, opt ...TestOpt) {
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||
|
||||
sb, closer, err := newSandbox(ctx, br, getMirror(), mv)
|
||||
sb, closer, err := newSandbox(ctx, t, br, getMirror(), mv)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { _ = closer() })
|
||||
defer func() {
|
||||
|
54
vendor/github.com/moby/buildkit/util/testutil/integration/sandbox.go
generated
vendored
54
vendor/github.com/moby/buildkit/util/testutil/integration/sandbox.go
generated
vendored
@ -5,11 +5,15 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/shlex"
|
||||
"github.com/moby/buildkit/util/bklog"
|
||||
@ -18,6 +22,8 @@ import (
|
||||
|
||||
const buildkitdConfigFile = "buildkitd.toml"
|
||||
|
||||
const maxSandboxTimeout = 5 * time.Minute
|
||||
|
||||
type sandbox struct {
|
||||
Backend
|
||||
|
||||
@ -79,7 +85,7 @@ func (sb *sandbox) Value(k string) interface{} {
|
||||
return sb.mv.values[k].value
|
||||
}
|
||||
|
||||
func newSandbox(ctx context.Context, w Worker, mirror string, mv matrixValue) (s Sandbox, cl func() error, err error) {
|
||||
func newSandbox(ctx context.Context, t *testing.T, w Worker, mirror string, mv matrixValue) (s Sandbox, cl func() error, err error) {
|
||||
cfg := &BackendConfig{
|
||||
Logs: make(map[string]*bytes.Buffer),
|
||||
}
|
||||
@ -110,6 +116,28 @@ func newSandbox(ctx context.Context, w Worker, mirror string, mv matrixValue) (s
|
||||
}
|
||||
deferF.Append(closer)
|
||||
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
|
||||
go func() {
|
||||
timeout := maxSandboxTimeout
|
||||
if strings.Contains(t.Name(), "ExtraTimeout") {
|
||||
timeout *= 3
|
||||
}
|
||||
timeoutContext, cancelTimeout := context.WithTimeoutCause(ctx, timeout, errors.WithStack(context.DeadlineExceeded))
|
||||
defer cancelTimeout()
|
||||
<-timeoutContext.Done()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
t.Logf("sandbox timeout reached, stopping worker")
|
||||
if addr := b.DebugAddress(); addr != "" {
|
||||
printBuildkitdDebugLogs(t, addr)
|
||||
}
|
||||
cancel(errors.WithStack(context.Canceled))
|
||||
}
|
||||
}()
|
||||
|
||||
return &sandbox{
|
||||
Backend: b,
|
||||
logs: cfg.Logs,
|
||||
@ -120,6 +148,30 @@ func newSandbox(ctx context.Context, w Worker, mirror string, mv matrixValue) (s
|
||||
}, cl, nil
|
||||
}
|
||||
|
||||
func printBuildkitdDebugLogs(t *testing.T, addr string) {
|
||||
if !strings.HasPrefix(addr, socketScheme) {
|
||||
t.Logf("invalid debug address %q", addr)
|
||||
return
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: &http.Transport{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
|
||||
return dialPipe(strings.TrimPrefix(addr, socketScheme))
|
||||
}}}
|
||||
|
||||
resp, err := client.Get("http://localhost/debug/pprof/goroutine?debug=2") //nolint:noctx // never cancel
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get debug logs: %v", err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
dt, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read debug logs: %v", err)
|
||||
return
|
||||
}
|
||||
t.Logf("buildkitd debug logs:\n%s", dt)
|
||||
}
|
||||
|
||||
func RootlessSupported(uid int) bool {
|
||||
cmd := exec.Command("sudo", "-u", fmt.Sprintf("#%d", uid), "-i", "--", "exec", "unshare", "-U", "true") //nolint:gosec // test utility
|
||||
b, err := cmd.CombinedOutput()
|
||||
|
Reference in New Issue
Block a user