vendor: github.com/moby/buildkit v0.13.0

full diff: https://github.com/moby/buildkit/compare/v0.13.0-rc3...v0.13.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-03-06 11:54:03 +01:00
parent 4046928978
commit 0f30791a0d
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A
22 changed files with 123 additions and 66 deletions

View file

@ -60,7 +60,7 @@ require (
github.com/miekg/dns v1.1.57
github.com/mistifyio/go-zfs/v3 v3.0.1
github.com/mitchellh/copystructure v1.2.0
github.com/moby/buildkit v0.13.0-rc3
github.com/moby/buildkit v0.13.0
github.com/moby/docker-image-spec v1.3.1
github.com/moby/ipvs v1.1.0
github.com/moby/locker v1.0.1
@ -87,7 +87,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/tonistiigi/fsutil v0.0.0-20240223190444-7a889f53dbf6
github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5
github.com/tonistiigi/go-archvariant v1.0.0
github.com/vbatts/tar-split v0.11.5
github.com/vishvananda/netlink v1.2.1-beta.2

View file

@ -38,8 +38,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Graylog2/go-gelf v0.0.0-20191017102106-1550ee647df0 h1:cOjLyhBhe91glgZZNbQUg9BJC57l6BiSKov0Ivv7k0U=
github.com/Graylog2/go-gelf v0.0.0-20191017102106-1550ee647df0/go.mod h1:fBaQWrftOD5CrVCUfoYGHs4X4VViTuGOXA8WloCjTY0=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
@ -478,8 +476,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
github.com/moby/buildkit v0.13.0-rc3 h1:Dns5Ixnv4OH1MyLZy7S4G2m+MLwp2YEqrPPzEzfw7Tw=
github.com/moby/buildkit v0.13.0-rc3/go.mod h1:5pRtk7Wuv929XRIp9tqPdq07mrnBpXAUoOYYfOj0nhA=
github.com/moby/buildkit v0.13.0 h1:reVR1Y+rbNIUQ9jf0Q1YZVH5a/nhOixZsl+HJ9qQEGI=
github.com/moby/buildkit v0.13.0/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ=
@ -671,8 +669,8 @@ github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0=
github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tonistiigi/fsutil v0.0.0-20240223190444-7a889f53dbf6 h1:v9u6pmdUkarXL/1S/6LGcG9wsiBLd9N/WyJq/Y9WPcg=
github.com/tonistiigi/fsutil v0.0.0-20240223190444-7a889f53dbf6/go.mod h1:vbbYqJlnswsbJqWUcJN8fKtBhnEgldDrcagTgnBVKKM=
github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5 h1:oZS8KCqAg62sxJkEq/Ppzqrb6EooqzWtL8Oaex7bc5c=
github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5/go.mod h1:vbbYqJlnswsbJqWUcJN8fKtBhnEgldDrcagTgnBVKKM=
github.com/tonistiigi/go-actions-cache v0.0.0-20240227172821-a0b64f338598 h1:DA/NDC0YbMdnfcOSUzAnbUZE6dSM54d+0hrBqG+bOfs=
github.com/tonistiigi/go-actions-cache v0.0.0-20240227172821-a0b64f338598/go.mod h1:anhKd3mnC1shAbQj1Q4IJ+w6xqezxnyDYlx/yKa7IXM=
github.com/tonistiigi/go-archvariant v1.0.0 h1:5LC1eDWiBNflnTF1prCiX09yfNHIxDC/aukdhCdTyb0=

View file

@ -12,7 +12,6 @@ import (
resourcestypes "github.com/moby/buildkit/executor/resources/types"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/network"
"github.com/prometheus/procfs"
)
@ -182,7 +181,7 @@ type Monitor struct {
}
type NetworkSampler interface {
Sample() (*network.Sample, error)
Sample() (*resourcestypes.NetworkSample, error)
}
type RecordOpt struct {

View file

@ -3,8 +3,6 @@ package types
import (
"context"
"time"
"github.com/moby/buildkit/util/network"
)
type Recorder interface {
@ -23,18 +21,29 @@ type Samples struct {
// Sample represents a wrapper for sampled data of cgroupv2 controllers
type Sample struct {
//nolint
Timestamp_ time.Time `json:"timestamp"`
CPUStat *CPUStat `json:"cpuStat,omitempty"`
MemoryStat *MemoryStat `json:"memoryStat,omitempty"`
IOStat *IOStat `json:"ioStat,omitempty"`
PIDsStat *PIDsStat `json:"pidsStat,omitempty"`
NetStat *network.Sample `json:"netStat,omitempty"`
Timestamp_ time.Time `json:"timestamp"`
CPUStat *CPUStat `json:"cpuStat,omitempty"`
MemoryStat *MemoryStat `json:"memoryStat,omitempty"`
IOStat *IOStat `json:"ioStat,omitempty"`
PIDsStat *PIDsStat `json:"pidsStat,omitempty"`
NetStat *NetworkSample `json:"netStat,omitempty"`
}
func (s *Sample) Timestamp() time.Time {
return s.Timestamp_
}
type NetworkSample struct {
RxBytes int64 `json:"rxBytes,omitempty"`
RxPackets int64 `json:"rxPackets,omitempty"`
RxErrors int64 `json:"rxErrors,omitempty"`
RxDropped int64 `json:"rxDropped,omitempty"`
TxBytes int64 `json:"txBytes,omitempty"`
TxPackets int64 `json:"txPackets,omitempty"`
TxErrors int64 `json:"txErrors,omitempty"`
TxDropped int64 `json:"txDropped,omitempty"`
}
// CPUStat represents the sampling state of the cgroupv2 CPU controller
type CPUStat struct {
UsageNanos *uint64 `json:"usageNanos,omitempty"`

View file

@ -1252,18 +1252,30 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error {
a = a.Copy(st, f, dest, opts...)
}
} else {
var patterns []string
if cfg.parents {
// detect optional pivot point
parent, pattern, ok := strings.Cut(src, "/./")
if !ok {
pattern = src
src = "/"
} else {
src = parent
}
pattern, err = system.NormalizePath("/", pattern, d.platform.OS, false)
if err != nil {
return errors.Wrap(err, "removing drive letter")
}
patterns = []string{strings.TrimPrefix(pattern, "/")}
}
src, err = system.NormalizePath("/", src, d.platform.OS, false)
if err != nil {
return errors.Wrap(err, "removing drive letter")
}
var patterns []string
if cfg.parents {
path := strings.TrimPrefix(src, "/")
patterns = []string{path}
src = "/"
}
opts := append([]llb.CopyOption{&llb.CopyInfo{
Mode: mode,
FollowSymlinks: true,

View file

@ -334,17 +334,20 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
}
var flExcludes *Flag
var flParents *Flag
// silently ignore if not -labs
if excludePatternsEnabled {
flExcludes = req.flags.AddStrings("exclude")
}
if parentsEnabled {
flParents = req.flags.AddBool("parents", false)
}
flChown := req.flags.AddString("chown", "")
flFrom := req.flags.AddString("from", "")
flChmod := req.flags.AddString("chmod", "")
flLink := req.flags.AddBool("link", false)
flParents := req.flags.AddBool("parents", false)
if err := req.flags.Parse(); err != nil {
return nil, err
}
@ -361,7 +364,7 @@ func parseCopy(req parseRequest) (*CopyCommand, error) {
Chown: flChown.Value,
Chmod: flChmod.Value,
Link: flLink.Value == "true",
Parents: (flParents.Value == "true") && parentsEnabled, // silently ignore if not -labs
Parents: flParents != nil && flParents.Value == "true",
ExcludePatterns: stringValuesFromFlagIfPossible(flExcludes),
}, nil
}

View file

@ -361,7 +361,7 @@ func (b *bindMount) Mount() ([]mount.Mount, func() error, error) {
return []mount.Mount{{
Type: "bind",
Source: b.dir,
Options: []string{"bind", "ro"},
Options: []string{"bind", "ro", "nosuid", "nodev", "noexec"},
}}, func() error { return nil }, nil
}
func (b *bindMount) IdentityMapping() *idtools.IdentityMapping {

View file

@ -196,7 +196,7 @@ func docopy(ctx context.Context, src, dest string, action pb.FileActionCopy, u *
for _, s := range m {
if action.AttemptUnpackDockerCompatibility {
if ok, err := unpack(ctx, src, s, dest, destPath, ch, timestampToTime(action.Timestamp)); err != nil {
if ok, err := unpack(src, s, dest, destPath, ch, timestampToTime(action.Timestamp), idmap); err != nil {
return err
} else if ok {
continue

View file

@ -2,17 +2,17 @@ package file
import (
"archive/tar"
"context"
"os"
"time"
"github.com/containerd/continuity/fs"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/chrootarchive"
"github.com/docker/docker/pkg/idtools"
copy "github.com/tonistiigi/fsutil/copy"
)
func unpack(ctx context.Context, srcRoot string, src string, destRoot string, dest string, ch copy.Chowner, tm *time.Time) (bool, error) {
func unpack(srcRoot string, src string, destRoot string, dest string, ch copy.Chowner, tm *time.Time, idmap *idtools.IdentityMapping) (bool, error) {
src, err := fs.RootPath(srcRoot, src)
if err != nil {
return false, err
@ -35,7 +35,13 @@ func unpack(ctx context.Context, srcRoot string, src string, destRoot string, de
}
defer file.Close()
return true, chrootarchive.Untar(file, dest, nil)
opts := &archive.TarOptions{
BestEffortXattrs: true,
}
if idmap != nil {
opts.IDMap = *idmap
}
return true, chrootarchive.Untar(file, dest, opts)
}
func isArchivePath(path string) bool {

View file

@ -78,6 +78,11 @@ func SupportedPlatforms(noCache bool) []ocispecs.Platform {
arr = append(arr, linux(p))
}
}
if p := "loong64"; def.Architecture != p {
if _, err := loong64Supported(); err == nil {
arr = append(arr, linux(p))
}
}
if p := "arm"; def.Architecture != p {
if _, err := armSupported(); err == nil {
p := linux("arm")
@ -144,6 +149,11 @@ func WarnIfUnsupported(pfs []ocispecs.Platform) {
printPlatformWarning(p, err)
}
}
if p.Architecture == "loong64" {
if _, err := loong64Supported(); err != nil {
printPlatformWarning(p, err)
}
}
if p.Architecture == "arm" {
if _, err := armSupported(); err != nil {
printPlatformWarning(p, err)

View file

@ -0,0 +1,9 @@
//go:build !loong64
// +build !loong64
package archutil
// This file is generated by running "make archutil".
// Do not edit manually.
const Binaryloong64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x08\x6f\x03\x03\x83\x02\x88\x76\x80\x8a\x5f\x80\xd2\xce\x60\x31\x0b\x06\x26\x06\x07\x06\x66\x06\x26\x06\x90\x1a\x56\x06\x14\xa0\xc0\x88\x44\xef\x81\x0a\xc2\x68\x98\x81\x81\x4f\x4b\x52\xd8\x18\x88\x07\x02\x50\x9a\x85\x41\x94\x81\xbb\xa4\x91\x99\x81\x41\x9b\x81\x41\xaf\x38\xa3\xb8\xa4\xa8\x24\x31\x89\x41\xaf\x24\xb5\xa2\x84\x81\x0a\x80\x9b\x81\x01\xec\x27\x98\xdb\x60\xe1\xb0\x01\xca\xe7\x41\x53\xcf\x88\x85\xcf\x8c\xc5\x5c\x98\xff\x05\x09\xe8\x07\x04\x00\x00\xff\xff\x5f\xc5\x9b\x9d\x90\x01\x00\x00"

View file

@ -0,0 +1,8 @@
//go:build !loong64
// +build !loong64
package archutil
func loong64Supported() (string, error) {
return check("loong64", Binaryloong64)
}

View file

@ -0,0 +1,7 @@
//go:build loong64
package archutil
func loong64Supported() (string, error) {
return "", nil
}

View file

@ -10,6 +10,7 @@ import (
cni "github.com/containerd/go-cni"
"github.com/gofrs/flock"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/network"
@ -333,8 +334,8 @@ type cniNS struct {
lastUsed time.Time
vethName string
canSample bool
offsetSample *network.Sample
prevSample *network.Sample
offsetSample *resourcestypes.NetworkSample
prevSample *resourcestypes.NetworkSample
}
func (ns *cniNS) Set(s *specs.Spec) error {
@ -352,11 +353,11 @@ func (ns *cniNS) Close() error {
return nil
}
func (ns *cniNS) Sample() (*network.Sample, error) {
func (ns *cniNS) Sample() (*resourcestypes.NetworkSample, error) {
if !ns.canSample {
return nil, nil
}
var s *network.Sample
var s *resourcestypes.NetworkSample
fn := func(_ context.Context) error {
var err error
s, err = ns.sample()

View file

@ -9,12 +9,12 @@ import (
"syscall"
"github.com/containernetworking/plugins/pkg/ns"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/network"
"github.com/pkg/errors"
)
func (ns *cniNS) sample() (*network.Sample, error) {
func (ns *cniNS) sample() (*resourcestypes.NetworkSample, error) {
dirfd, err := syscall.Open(filepath.Join("/sys/class/net", ns.vethName, "statistics"), syscall.O_RDONLY, 0)
if err != nil {
if errors.Is(err, syscall.ENOENT) || errors.Is(err, syscall.ENOTDIR) {
@ -25,7 +25,7 @@ func (ns *cniNS) sample() (*network.Sample, error) {
defer syscall.Close(dirfd)
buf := make([]byte, 32)
stat := &network.Sample{}
stat := &resourcestypes.NetworkSample{}
for _, name := range []string{"tx_bytes", "rx_bytes", "tx_packets", "rx_packets", "tx_errors", "rx_errors", "tx_dropped", "rx_dropped"} {
n, err := readFileAt(dirfd, name, buf)

View file

@ -6,10 +6,10 @@ package cniprovider
import (
"context"
"github.com/moby/buildkit/util/network"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
)
func (ns *cniNS) sample() (*network.Sample, error) {
func (ns *cniNS) sample() (*resourcestypes.NetworkSample, error) {
return nil, nil
}

View file

@ -7,6 +7,7 @@ import (
"context"
"github.com/containerd/containerd/oci"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
@ -36,6 +37,6 @@ func (h *hostNS) Close() error {
return nil
}
func (h *hostNS) Sample() (*Sample, error) {
func (h *hostNS) Sample() (*resourcestypes.NetworkSample, error) {
return nil, nil
}

View file

@ -4,20 +4,10 @@ import (
"context"
"io"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
type Sample struct {
RxBytes int64 `json:"rxBytes,omitempty"`
RxPackets int64 `json:"rxPackets,omitempty"`
RxErrors int64 `json:"rxErrors,omitempty"`
RxDropped int64 `json:"rxDropped,omitempty"`
TxBytes int64 `json:"txBytes,omitempty"`
TxPackets int64 `json:"txPackets,omitempty"`
TxErrors int64 `json:"txErrors,omitempty"`
TxDropped int64 `json:"txDropped,omitempty"`
}
// Provider interface for Network
type Provider interface {
io.Closer
@ -30,5 +20,5 @@ type Namespace interface {
// Set the namespace on the spec
Set(*specs.Spec) error
Sample() (*Sample, error)
Sample() (*resourcestypes.NetworkSample, error)
}

View file

@ -3,6 +3,7 @@ package network
import (
"context"
resourcestypes "github.com/moby/buildkit/executor/resources/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
@ -32,6 +33,6 @@ func (h *noneNS) Close() error {
return nil
}
func (h *noneNS) Sample() (*Sample, error) {
func (h *noneNS) Sample() (*resourcestypes.NetworkSample, error) {
return nil, nil
}

View file

@ -27,7 +27,7 @@ func DefaultPathEnv(os string) string {
// NormalizePath cleans the path based on the operating system the path is meant for.
// It takes into account a potential parent path, and will join the path to the parent
// if the path is relative. Additionally, it will apply the folliwing rules:
// if the path is relative. Additionally, it will apply the following rules:
// - always return an absolute path
// - always strip drive letters for Windows paths
// - optionally keep the trailing slashes on paths

View file

@ -43,13 +43,14 @@ type sendHandle struct {
}
type sender struct {
conn Stream
fs FS
files map[uint32]string
mu sync.RWMutex
progressCb func(int, bool)
progressCurrent int
sendpipeline chan *sendHandle
conn Stream
fs FS
files map[uint32]string
mu sync.RWMutex
progressCb func(int, bool)
progressCurrent int
progressCurrentMu sync.Mutex
sendpipeline chan *sendHandle
}
func (s *sender) run(ctx context.Context) error {
@ -112,6 +113,8 @@ func (s *sender) run(ctx context.Context) error {
func (s *sender) updateProgress(size int, last bool) {
if s.progressCb != nil {
s.progressCurrentMu.Lock()
defer s.progressCurrentMu.Unlock()
s.progressCurrent += size
s.progressCb(s.progressCurrent, last)
}

4
vendor/modules.txt vendored
View file

@ -702,7 +702,7 @@ github.com/mitchellh/hashstructure/v2
# github.com/mitchellh/reflectwalk v1.0.2
## explicit
github.com/mitchellh/reflectwalk
# github.com/moby/buildkit v0.13.0-rc3
# github.com/moby/buildkit v0.13.0
## explicit; go 1.21
github.com/moby/buildkit/api/services/control
github.com/moby/buildkit/api/types
@ -1070,7 +1070,7 @@ github.com/syndtr/gocapability/capability
# github.com/tinylib/msgp v1.1.8
## explicit; go 1.15
github.com/tinylib/msgp/msgp
# github.com/tonistiigi/fsutil v0.0.0-20240223190444-7a889f53dbf6
# github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5
## explicit; go 1.20
github.com/tonistiigi/fsutil
github.com/tonistiigi/fsutil/copy