Allow ro mounts without a parent
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
eeb88554ac
commit
c48e9a763f
1 changed files with 12 additions and 4 deletions
|
@ -206,7 +206,7 @@ func (o *Snapshotter) newActiveDir(key string, readonly bool) (*activeDir, error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := os.MkdirAll(path, 0700); err != nil {
|
if err := os.MkdirAll(filepath.Join(path, "fs"), 0700); err != nil {
|
||||||
a.delete()
|
a.delete()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -309,13 +309,21 @@ func (a *activeDir) mounts(c *cache) ([]containerd.Mount, error) {
|
||||||
}
|
}
|
||||||
if len(parents) == 0 {
|
if len(parents) == 0 {
|
||||||
// if we only have one layer/no parents then just return a bind mount as overlay
|
// if we only have one layer/no parents then just return a bind mount as overlay
|
||||||
// will not work, readonly always has parent
|
// will not work
|
||||||
|
roFlag := "rw"
|
||||||
|
if _, err := os.Stat(filepath.Join(a.path, "work")); err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
roFlag = "ro"
|
||||||
|
}
|
||||||
|
|
||||||
return []containerd.Mount{
|
return []containerd.Mount{
|
||||||
{
|
{
|
||||||
Source: filepath.Join(a.path, "fs"),
|
Source: filepath.Join(a.path, "fs"),
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Options: []string{
|
Options: []string{
|
||||||
"rw",
|
roFlag,
|
||||||
"rbind",
|
"rbind",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -323,7 +331,7 @@ func (a *activeDir) mounts(c *cache) ([]containerd.Mount, error) {
|
||||||
}
|
}
|
||||||
var options []string
|
var options []string
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(a.path, "fs")); err == nil {
|
if _, err := os.Stat(filepath.Join(a.path, "work")); err == nil {
|
||||||
options = append(options,
|
options = append(options,
|
||||||
fmt.Sprintf("workdir=%s", filepath.Join(a.path, "work")),
|
fmt.Sprintf("workdir=%s", filepath.Join(a.path, "work")),
|
||||||
fmt.Sprintf("upperdir=%s", filepath.Join(a.path, "fs")),
|
fmt.Sprintf("upperdir=%s", filepath.Join(a.path, "fs")),
|
||||||
|
|
Loading…
Add table
Reference in a new issue