Skip to content

Commit

Permalink
Merge pull request #1990 from TomSweeneyRedHat/dev/tsweeney/acel244-1.51
Browse files Browse the repository at this point in the history
[release-1.51] Backport ignore chown errors in additionalimagestore
  • Loading branch information
TomSweeneyRedHat committed Jul 11, 2024
2 parents f9fed3f + 4a94de7 commit d270930
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.51.0
1.51.1
2 changes: 1 addition & 1 deletion drivers/aufs/aufs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ func BenchmarkConcurrentAccess(b *testing.B) {
}

parent := ids[1]
ids = append(ids[2:])
ids = ids[2:]

chErr := make(chan error, numConcurrent)
var outerGroup sync.WaitGroup
Expand Down
42 changes: 33 additions & 9 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -1670,13 +1670,21 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
}

if err := idtools.MkdirAllAs(diffDir, perms, rootUID, rootGID); err != nil {
return "", err
if !inAdditionalStore {
return "", err
}
// if it is in an additional store, do not fail if the directory already exists
if _, err2 := os.Stat(diffDir); err2 != nil {
return "", err
}
}

mergedDir := path.Join(workDirBase, "merged")
// Create the driver merged dir
if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
// Attempt to create the merged dir only if it doesn't exist.
if _, err := os.Stat(mergedDir); err != nil && os.IsNotExist(err) {
if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
}
}
if count := d.ctr.Increment(mergedDir); count > 1 {
return mergedDir, nil
Expand Down Expand Up @@ -1841,7 +1849,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO

// Put unmounts the mount path created for the give id.
func (d *Driver) Put(id string) error {
dir := d.dir(id)
dir, _, inAdditionalStore := d.dir2(id)
if _, err := os.Stat(dir); err != nil {
return err
}
Expand Down Expand Up @@ -1902,11 +1910,27 @@ func (d *Driver) Put(id string) error {
}
}

if err := unix.Rmdir(mountpoint); err != nil && !os.IsNotExist(err) {
logrus.Debugf("Failed to remove mountpoint %s overlay: %s - %v", id, mountpoint, err)
return fmt.Errorf("removing mount point %q: %w", mountpoint, err)
}
if !inAdditionalStore {
uid, gid := int(0), int(0)
fi, err := os.Stat(mountpoint)
if err != nil {
return err
}
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
uid, gid = int(stat.Uid), int(stat.Gid)
}

tmpMountpoint := path.Join(dir, "merged.1")
if err := idtools.MkdirAs(tmpMountpoint, 0o700, uid, gid); err != nil && !errors.Is(err, os.ErrExist) {
return err
}
// rename(2) can be used on an empty directory, as it is the mountpoint after umount, and it retains
// its atomic semantic. In this way the "merged" directory is never removed.
if err := unix.Rename(tmpMountpoint, mountpoint); err != nil {
logrus.Debugf("Failed to replace mountpoint %s overlay: %s - %v", id, mountpoint, err)
return fmt.Errorf("replacing mount point %q: %w", mountpoint, err)
}
}
return nil
}

Expand Down
5 changes: 4 additions & 1 deletion tests/overlay-recreate.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ load helpers
storage unmount "$lowerlayer"
storage mount "$midlayer"
storage unmount "$midlayer"
storage mount "$upperlayer"
run storage --debug=false mount "$upperlayer"
merged_dir="$output"
storage unmount "$upperlayer"
# okay, but how about this?
rm -v ${TESTDIR}/root/overlay/*/link
Expand All @@ -27,6 +28,8 @@ load helpers
storage unmount "$lowerlayer"
storage mount "$midlayer"
storage unmount "$midlayer"
# check it works if we delete the merged directory.
rmdir "$merged_dir"
storage mount "$upperlayer"
storage unmount "$upperlayer"
# okay, not bad, kid.
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ $(BUILDDIR)/git-validation:
$(BUILDDIR)/go-md2man:
$(call go-build,./vendor/github.com/cpuguy83/go-md2man)

$(BUILDDIR)/golangci-lint: VERSION=v1.51.2
$(BUILDDIR)/golangci-lint: VERSION=v1.55.2
$(BUILDDIR)/golangci-lint:
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/$(VERSION)/install.sh | sh -s -- -b ./$(BUILDDIR) $(VERSION)

0 comments on commit d270930

Please sign in to comment.