Merge pull request #46471 from foundriesio/atomic-layer-data-write
daemon: overlay2: Write layer metadata atomically
This commit is contained in:
commit
01cc1cc923
1 changed files with 4 additions and 3 deletions
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/docker/docker/pkg/containerfs"
|
||||
"github.com/docker/docker/pkg/directory"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/quota"
|
||||
units "github.com/docker/go-units"
|
||||
|
@ -383,7 +384,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
|||
}
|
||||
|
||||
// Write link id to link file
|
||||
if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
|
||||
if err := ioutils.AtomicWriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -396,7 +397,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
|||
return err
|
||||
}
|
||||
|
||||
if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
|
||||
if err := ioutils.AtomicWriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -405,7 +406,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
|||
return err
|
||||
}
|
||||
if lower != "" {
|
||||
if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
|
||||
if err := ioutils.AtomicWriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue