internal/pkg: respect mount order for overlay temp
All checks were successful
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m55s
Test / ShareFS (push) Successful in 4m51s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hakurei (push) Successful in 5m26s
Test / Hpkg (push) Successful in 5m28s
Test / Hakurei (race detector) (push) Successful in 4m39s
Test / Flake checks (push) Successful in 1m48s
All checks were successful
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m55s
Test / ShareFS (push) Successful in 4m51s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hakurei (push) Successful in 5m26s
Test / Hpkg (push) Successful in 5m28s
Test / Hakurei (race detector) (push) Successful in 4m39s
Test / Flake checks (push) Successful in 1m48s
Setting it up after everything else prevents covering files in /tmp. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -186,11 +186,15 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) {
|
|||||||
cures = runtime.NumCPU()
|
cures = runtime.NumCPU()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overlayTempIndex := -1
|
||||||
paths := make([][2]*check.Absolute, len(a.paths))
|
paths := make([][2]*check.Absolute, len(a.paths))
|
||||||
for i, p := range a.paths {
|
for i, p := range a.paths {
|
||||||
if p.P == nil || p.A == nil {
|
if p.P == nil || p.A == nil {
|
||||||
return os.ErrInvalid
|
return os.ErrInvalid
|
||||||
}
|
}
|
||||||
|
if p.P.Is(fhs.AbsTmp) {
|
||||||
|
overlayTempIndex = i
|
||||||
|
}
|
||||||
paths[i][1] = p.P
|
paths[i][1] = p.P
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,31 +279,11 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) {
|
|||||||
if len(paths) > 0 && paths[0][1].Is(fhs.AbsRoot) {
|
if len(paths) > 0 && paths[0][1].Is(fhs.AbsRoot) {
|
||||||
z.OverlayEphemeral(fhs.AbsRoot, paths[0][0])
|
z.OverlayEphemeral(fhs.AbsRoot, paths[0][0])
|
||||||
paths = paths[1:]
|
paths = paths[1:]
|
||||||
|
overlayTempIndex--
|
||||||
}
|
}
|
||||||
var overlayTemp *check.Absolute
|
|
||||||
for _, b := range paths {
|
for i, b := range paths {
|
||||||
if b[1].Is(fhs.AbsTmp) {
|
if i == overlayTempIndex {
|
||||||
if overlayTemp != nil {
|
|
||||||
z.Bind(overlayTemp, fhs.AbsTmp, 0)
|
|
||||||
}
|
|
||||||
overlayTemp = b[0]
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
z.Bind(b[0], b[1], 0)
|
|
||||||
}
|
|
||||||
work := c.GetWorkDir()
|
|
||||||
z.Bind(
|
|
||||||
work,
|
|
||||||
fhs.AbsRoot.Append("work"),
|
|
||||||
std.BindWritable|std.BindEnsure,
|
|
||||||
)
|
|
||||||
if overlayTemp == nil {
|
|
||||||
z.Bind(
|
|
||||||
c.GetTempDir(),
|
|
||||||
fhs.AbsTmp,
|
|
||||||
std.BindWritable|std.BindEnsure,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
temp := c.GetTempDir()
|
temp := c.GetTempDir()
|
||||||
tempUpper := temp.Append("upper")
|
tempUpper := temp.Append("upper")
|
||||||
if err = os.MkdirAll(tempUpper.String(), 0700); err != nil {
|
if err = os.MkdirAll(tempUpper.String(), 0700); err != nil {
|
||||||
@@ -313,7 +297,23 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) {
|
|||||||
fhs.AbsTmp,
|
fhs.AbsTmp,
|
||||||
tempUpper,
|
tempUpper,
|
||||||
tempWork,
|
tempWork,
|
||||||
overlayTemp,
|
b[0],
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
z.Bind(b[0], b[1], 0)
|
||||||
|
}
|
||||||
|
work := c.GetWorkDir()
|
||||||
|
z.Bind(
|
||||||
|
work,
|
||||||
|
fhs.AbsRoot.Append("work"),
|
||||||
|
std.BindWritable|std.BindEnsure,
|
||||||
|
)
|
||||||
|
if overlayTempIndex < 0 {
|
||||||
|
z.Bind(
|
||||||
|
c.GetTempDir(),
|
||||||
|
fhs.AbsTmp,
|
||||||
|
std.BindWritable|std.BindEnsure,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
z.Proc(fhs.AbsProc).Dev(fhs.AbsDev, true)
|
z.Proc(fhs.AbsProc).Dev(fhs.AbsDev, true)
|
||||||
|
|||||||
16
internal/pkg/testdata/main.go
vendored
16
internal/pkg/testdata/main.go
vendored
@@ -144,22 +144,24 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if overlayTmp {
|
||||||
|
next() // testtool artifact
|
||||||
|
if m.Root != "/" || m.Target != "/tmp" ||
|
||||||
|
m.Source != "overlay" || m.FsType != "overlay" {
|
||||||
|
log.Fatal("unexpected temp mount entry")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
if path.Base(m.Root) != ident || m.Target != "/work" {
|
if path.Base(m.Root) != ident || m.Target != "/work" {
|
||||||
log.Fatal("unexpected work mount entry")
|
log.Fatal("unexpected work mount entry")
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
|
||||||
if !overlayTmp {
|
if !overlayTmp {
|
||||||
|
next()
|
||||||
if path.Base(m.Root) != ident || m.Target != "/tmp" {
|
if path.Base(m.Root) != ident || m.Target != "/tmp" {
|
||||||
log.Fatal("unexpected temp mount entry")
|
log.Fatal("unexpected temp mount entry")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// testtool artifact
|
|
||||||
if m.Root != "/" || m.Target != "/tmp" ||
|
|
||||||
m.Source != "overlay" || m.FsType != "overlay" {
|
|
||||||
log.Fatal("unexpected temp mount entry")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
Reference in New Issue
Block a user