Skip to content

Commit

Permalink
[release-1.51] overlay: create the merged path only if it does not exist
Browse files Browse the repository at this point in the history
follow-up for ccb70a7

more information here: containers#1827 (comment)

Addresses: https://issues.redhat.com/browse/ACCELFIX-244

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
  • Loading branch information
giuseppe authored and TomSweeneyRedHat committed Jun 27, 2024
1 parent f538ebb commit 7f8ed41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -1680,9 +1680,11 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
}

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
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 7f8ed41

Please sign in to comment.