The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6114

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Starting LXD with a container running that has a non-required dev already existing on host, fails to add inotify for that device with `Failed to add "/tmp/testdev" to inotify targets: not a directory` which means it also doesnt get removed if the file is removed.

@stgraber I thought this might be useful to cherry pick into stable releases before I port it over to the `device` package.
From e835e10beb16eb9dee00131e1cecad22ee7abac6 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Thu, 22 Aug 2019 18:02:20 +0100
Subject: [PATCH 1/2] container/lxc: Fixes inotify dynamic hotplug on container
 start when device exists

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/container_lxc.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 95397799eb..b72f37384f 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2696,7 +2696,7 @@ func (c *containerLXC) startCommon() (string, []func() 
error, error) {
                                }
                                srcPath = shared.HostPath(srcPath)
 
-                               err = 
deviceInotifyAddClosestLivingAncestor(c.state, srcPath)
+                               err = 
deviceInotifyAddClosestLivingAncestor(c.state, filepath.Dir(srcPath))
                                if err != nil {
                                        logger.Errorf("Failed to add \"%s\" to 
inotify targets", srcPath)
                                        return "", postStartHooks, err

From 9ab849025e779562eca3d1f80e3b76b537a5b74f Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Thu, 22 Aug 2019 18:03:06 +0100
Subject: [PATCH 2/2] devices: Fixes dynamic hotplug of unix devices when they
 exist on startup

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/devices.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/devices.go b/lxd/devices.go
index 730764f5a6..6331214a9b 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -1087,11 +1087,11 @@ func deviceInotifyDirRescan(s *state.State) {
                        }
 
                        // and add its nearest existing ancestor.
-                       err = deviceInotifyAddClosestLivingAncestor(s, 
cleanDevPath)
+                       err = deviceInotifyAddClosestLivingAncestor(s, 
filepath.Dir(cleanDevPath))
                        if err != nil {
-                               logger.Errorf("Failed to add \"%s\" to inotify 
targets: %s", cleanDevPath, err)
+                               logger.Errorf("Failed to add \"%s\" to inotify 
targets: %s", filepath.Dir(cleanDevPath), err)
                        } else {
-                               logger.Debugf("Added \"%s\" to inotify 
targets", cleanDevPath)
+                               logger.Debugf("Added \"%s\" to inotify 
targets", filepath.Dir(cleanDevPath))
                        }
                }
        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to