Skip to content

Fix error removing diff path#34587

Merged
vieux merged 1 commit into
moby:masterfrom
cpuguy83:aufs_rm_errors
Aug 22, 2017
Merged

Fix error removing diff path#34587
vieux merged 1 commit into
moby:masterfrom
cpuguy83:aufs_rm_errors

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

In d42dbdd the code was re-arranged to
better report errors, and ignore non-errors.
In doing so we removed a deferred remove of the AUFS diff path, but did
not replace it with a non-deferred one.

This fixes the issue and makes the code a bit more readable.

Comment thread daemon/graphdriver/aufs/aufs.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the order of deletion changed in here? I think it makes more sense to remove mount before diffs because they are more likely to get EBUSY(and in some versions, you can't remove diff when it is mounted). And layers last as it should never fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to match the original defer ordering.
I'll double check this later. Fine either way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This indeed matches the order before #33960

@tiborvass
Copy link
Copy Markdown
Contributor

@cpuguy83 to make this easier for cherrypicking in a patch release, can we make this commit as minimal as possible, addressing the removed defer only?

I suggest you make it "more readable" in another PR, it's important for the diff to be small.

@tonistiigi
Copy link
Copy Markdown
Member

Should we add a cleanup of diff/*-removing to aufs.Init() ?

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Aug 21, 2017

@tonistiigi I was about to suggest the same, I think we should for ppl who installed 17.06.1

@tiborvass
Copy link
Copy Markdown
Contributor

@tonistiigi @vieux shouldn't that be only in the patch release, and not master?

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Aug 22, 2017

@tiborvass

if ppl go from 17.06.1 -> 17.07.0 they won't get the fix if we put it in the patch release only

@cpuguy83
Copy link
Copy Markdown
Member Author

to make this easier for cherrypicking in a patch release, can we make this commit as minimal as possible, addressing the removed defer only?

The primary reason I moved it out rather than keeping it all in one function is I needed to add additional error handling for the IsExist(Err) case where a remove fails, and now we have a dir that has been renamed but not removed, which just added to the complexity.

Should we add a cleanup of diff/*-removing to aufs.Init() ?
SGTM

@andrewhsu
Copy link
Copy Markdown
Contributor

Would it be suitable to have a unit test in the corresponding aufs_test.go?

@cpuguy83
Copy link
Copy Markdown
Member Author

Added tests to make sure that there's no -removing dir hanging around after Remove() and also that Init() cleans up dirs with -removing

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Aug 22, 2017

@tonistiigi @tiborvass LGTY now? Let's get this one in asap

Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread daemon/graphdriver/aufs/aufs_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted

In d42dbdd the code was re-arranged to
better report errors, and ignore non-errors.
In doing so we removed a deferred remove of the AUFS diff path, but did
not replace it with a non-deferred one.

This fixes the issue and makes the code a bit more readable.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@vieux
Copy link
Copy Markdown
Contributor

vieux commented Aug 22, 2017

LGTM

p := filepath.Join(root, path)
dirs, err := ioutil.ReadDir(p)
if err != nil {
logrus.WithError(err).WithField("dir", p).Error("error reading dir entries")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to mention aufs in the error message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless some higher caller already inserts that info


for _, path := range []string{"mnt", "diff"} {
p := filepath.Join(root, path)
dirs, err := ioutil.ReadDir(p)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit confusing to call the variable dirs because they may not all be dirs. Entries?

}
for _, dir := range dirs {
if strings.HasSuffix(dir.Name(), "-removing") {
logrus.WithField("dir", dir.Name()).Debug("Cleaning up stale layer dir")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention aufs

if strings.HasSuffix(dir.Name(), "-removing") {
logrus.WithField("dir", dir.Name()).Debug("Cleaning up stale layer dir")
if err := system.EnsureRemoveAll(filepath.Join(p, dir.Name())); err != nil {
logrus.WithField("dir", dir.Name()).WithError(err).Error("Error removing stale layer dir")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aufs

retries++
logger.Warnf("unmount failed due to EBUSY: retry count: %d", retries)
time.Sleep(100 * time.Millisecond)
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I can't see on the phone the whole function. Just want to make sure the return statement at the end the block is wanted and shouldn't instead be a logging statement followed by this removed continue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a continue at the end of a for loop, it was useless

@andrewhsu
Copy link
Copy Markdown
Contributor

andrewhsu commented Aug 22, 2017

Test LGTM: I've verified that without this fix, the tests added to aufs_test.go fail on the master branch:

$ make test-unit
...
--- FAIL: TestRemoveImage (0.00s)
	aufs_test.go:155: Error should not be nil because dirs with id 1-removing should be delted: diff
--- FAIL: TestInitStaleCleanup (0.02s)
	aufs_test.go:824: cleanup failed
FAIL
...

Nit-pick (not required for merge): in the future, it may be more helpful to have changes to tests as a separate git commit to the PR. Also, spelling: delted.

@tiborvass
Copy link
Copy Markdown
Contributor

@andrewhsu the spelling mistake was fixed already.

LGTM despite minor nitpicks

@vieux vieux merged commit bbcdc7d into moby:master Aug 22, 2017
@vieux
Copy link
Copy Markdown
Contributor

vieux commented Aug 22, 2017

let's do a follow up PR

@justlaputa
Copy link
Copy Markdown

@cpuguy83 hi, do you have plan to backport this fix to older version of docker, like 1.10 or 1.12?

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Sep 6, 2017

@judtlaputa this is a specific fix for a regression in 17.06.1.

@justlaputa
Copy link
Copy Markdown

@cpuguy83 oh, sorry. I should comment on the original PR #33960

pld-gitsync pushed a commit to pld-linux/docker-ce that referenced this pull request Sep 9, 2017
resolves annoying disk space eater "-removing" regression with aufs/diff

moby/moby#34587

moby/moby#21925 (comment)
https://stackoverflow.com/a/45798794
moby/moby#22207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants