E534 devmapper/Remove(): use Rmdir, ignore errors by kolyshkin · Pull Request #36438 · moby/moby · GitHub
[go: up one dir, main page]

Skip to content

Conversation

kolyshkin
Copy link
Contributor
  1. Replace EnsureRemoveAll() with Rmdir(), as here we are removing
    the container's mount point, which is already properly unmounted
    and is therefore an empty directory.

  2. Ignore the Rmdir() error (but log it unless it's ENOENT). This
    is a mount point, currently unmounted (i.e. an empty directory),
    and an older kernel can return EBUSY if e.g. the mount was
    leaked to other mount namespaces.

@codecov
Copy link
codecov bot commented Feb 28, 2018

Codecov Report

Merging #36438 into master will increase coverage by 0.01%.
The diff coverage is 60%.

@@            Coverage Diff             @@
##           master   #36438      +/-   ##
==========================================
+ Coverage   34.65%   34.66%   +0.01%     
==========================================
  Files         613      613              
  Lines       45375    45379       +4     
==========================================
+ Hits        15725    15732       +7     
  Misses      27588    27588              
+ Partials     2062     2059       -3

Copy link
Member
@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Left some nits, but "SGTM". Would like to have @cpuguy83 to have a look at least 😄

Copy link
Member

Choose a reason for hiding this comment

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

nit: this (and logrus) should be in the same group;

diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go
index e9d9e85aa..83a57f328 100644
--- a/daemon/graphdriver/devmapper/driver.go
+++ b/daemon/graphdriver/devmapper/driver.go
@@ -9,8 +9,6 @@ import (
        "path"
        "strconv"
 
-       "github.com/sirupsen/logrus"
-
        "github.com/docker/docker/daemon/graphdriver"
        "github.com/docker/docker/pkg/containerfs"
        "github.com/docker/docker/pkg/devicemapper"
@@ -18,7 +16,7 @@ import (
        "github.com/docker/docker/pkg/locker"
        "github.com/docker/docker/pkg/mount"
        units "github.com/docker/go-units"
-
+       "github.com/sirupsen/logrus"
        "golang.org/x/sys/unix"
 )

Copy link
Member

Choose a reason for hiding this comment

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

nit: s/as with an older kernel can/as an older kernel can/

Copy link
Member

Choose a reason for hiding this comment

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

perhaps

logrus.Warnf("unable to remove mountpoint %q: %s", mp, err)

("unable" or "failed" - used "unable" to make it look less as an important error)

Copy link
Member

Choose a reason for hiding this comment

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

WithField("module", "graphdriver/devicemapper")

Copy link
Member
@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM other than the log message.

Copy link
Member

Choose a reason for hiding this comment

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

WithField("module", "graphdriver/devicemapper")

@kolyshkin
Copy link
Contributor Author

WithField("module", "graphdriver/devicemapper")

devmapper uses logrus.WithField("storage-driver", "devicemapper") in some other messages.

aufs uses

logrus.WithFields(logrus.Fields{
                "module": "graphdriver",
                "driver": "aufs",
        }) 

I am in flux about which of the three to use. I guess I'll use the one already used by devmapper -- let me know if you want me to change it.

@kolyshkin
Copy link
Contributor Author

patch updated

Copy link
Member
@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Log message looks ok to me.

Is there a way to test for the situation we’re dealing with?

Copy link
Member

Choose a reason for hiding this comment

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

if you remove the blank line and gofmt is should sort the imports correctly 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case I wanted to separate "our" packages (ie github.com/docker/docker/*) from third-party ones. But maybe you're right, it makes little sense if the list is sorted, we clearly see docker/docker from others.

Blank line removed.

@thaJeztah
Copy link
Member

Should we have a tracking issue for standardizing those log properties among storage drivers, or not worth the effort? (could be a “beginners” issue for someone to work on)

@kolyshkin
Copy link
Contributor Author

Should we have a tracking issue for standardizing those log properties among
storage drivers, or not worth the effort? (could be a “beginners” issue for someone to work on)

Makes total sense to me

1. Replace EnsureRemoveAll() with Rmdir(), as here we are removing
   the container's mount point, which is already properly unmounted
   and is therefore an empty directory.

2. Ignore the Rmdir() error (but log it unless it's ENOENT). This
   is a mount point, currently unmounted (i.e. an empty directory),
   and an older kernel can return EBUSY if e.g. the mount was
   leaked to other mount namespaces.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

Is there a way to test for the situation we’re dealing with?

It's a combination of factors that should not happen when using a recent moby/moby, although I guess if you would use an older kernel (like RHEL/CentOS 7.3) and "organize" a mount point leak, you might end up seeing this. It seems way too complicated to setup for me.

@thaJeztah
Copy link
Member

Opened #36478 for tracking the "standardisation" of log-messages

Copy link
Member
@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants
0