vendor: update buildkit to v0.20.0-rc1

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-02-11 12:43:07 -08:00
parent 350d3f0f4b
commit 03569c2188
22 changed files with 1733 additions and 628 deletions

View File

@ -17,6 +17,7 @@ const (
var (
UserCNIConfigPath = filepath.Join(UserConfigDir(), "cni.json")
CDISpecDirs = []string{"/etc/cdi", "/var/run/cdi", "/etc/buildkit/cdi"}
)
// UserAddress typically returns /run/user/$UID/buildkit/buildkitd.sock

View File

@ -18,6 +18,7 @@ var (
var (
UserCNIConfigPath = DefaultCNIConfigPath
CDISpecDirs []string
)
func UserAddress() string {

View File

@ -60,12 +60,14 @@ type Sandbox interface {
NewRegistry() (string, error)
Value(string) interface{} // chosen matrix value
Name() string
CDISpecDir() string
}
// BackendConfig is used to configure backends created by a worker.
type BackendConfig struct {
Logs map[string]*bytes.Buffer
DaemonConfig []ConfigUpdater
CDISpecDir string
}
type Worker interface {

View File

@ -27,11 +27,12 @@ const maxSandboxTimeout = 5 * time.Minute
type sandbox struct {
Backend
logs map[string]*bytes.Buffer
cleanup *MultiCloser
mv matrixValue
ctx context.Context
name string
logs map[string]*bytes.Buffer
cleanup *MultiCloser
mv matrixValue
ctx context.Context
cdiSpecDir string
name string
}
func (sb *sandbox) Name() string {
@ -42,6 +43,10 @@ func (sb *sandbox) Context() context.Context {
return sb.ctx
}
func (sb *sandbox) CDISpecDir() string {
return sb.cdiSpecDir
}
func (sb *sandbox) Logs() map[string]*bytes.Buffer {
return sb.logs
}
@ -110,6 +115,15 @@ func newSandbox(ctx context.Context, t *testing.T, w Worker, mirror string, mv m
}
}()
cdiSpecDir, err := os.MkdirTemp("", "buildkit-integration-cdi")
if err != nil {
return nil, nil, errors.Wrap(err, "cannot create cdi spec dir")
}
deferF.Append(func() error {
return os.RemoveAll(cdiSpecDir)
})
cfg.CDISpecDir = cdiSpecDir
b, closer, err := w.New(ctx, cfg)
if err != nil {
return nil, nil, errors.Wrap(err, "creating worker")
@ -139,12 +153,13 @@ func newSandbox(ctx context.Context, t *testing.T, w Worker, mirror string, mv m
}()
return &sandbox{
Backend: b,
logs: cfg.Logs,
cleanup: deferF,
mv: mv,
ctx: ctx,
name: w.Name(),
Backend: b,
logs: cfg.Logs,
cleanup: deferF,
mv: mv,
ctx: ctx,
cdiSpecDir: cfg.CDISpecDir,
name: w.Name(),
}, cl, nil
}

View File

@ -47,7 +47,12 @@ func (s *OCI) New(ctx context.Context, cfg *integration.BackendConfig) (integrat
return nil, nil, err
}
// Include use of --oci-worker-labels to trigger https://github.com/moby/buildkit/pull/603
buildkitdArgs := []string{"buildkitd", "--oci-worker=true", "--containerd-worker=false", "--oci-worker-gc=false", "--oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true"}
buildkitdArgs := []string{"buildkitd",
"--oci-worker=true",
"--containerd-worker=false",
"--oci-worker-gc=false",
"--oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true",
}
if s.Snapshotter != "" {
buildkitdArgs = append(buildkitdArgs,

View File

@ -25,6 +25,20 @@ func (osp otelSocketPath) UpdateConfigFile(in string) string {
`, in, osp)
}
func withCDISpecDir(specDir string) integration.ConfigUpdater {
return cdiSpecDir(specDir)
}
type cdiSpecDir string
func (csd cdiSpecDir) UpdateConfigFile(in string) string {
return fmt.Sprintf(`%s
[cdi]
specDirs = [%q]
`, in, csd)
}
func runBuildkitd(
conf *integration.BackendConfig,
args []string,
@ -61,7 +75,11 @@ func runBuildkitd(
deferF.Append(func() error { return os.RemoveAll(tmpdir) })
cfgfile, err := integration.WriteConfig(
append(conf.DaemonConfig, withOTELSocketPath(getTraceSocketPath(tmpdir))))
append(conf.DaemonConfig,
withOTELSocketPath(getTraceSocketPath(tmpdir)),
withCDISpecDir(conf.CDISpecDir),
),
)
if err != nil {
return "", "", nil, err
}