From 164f02e5acaad9115ed996c759f74c6fa2fdac5f Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Thu, 26 Apr 2018 15:52:34 -0700 Subject: [PATCH] better handling for deleting node directories --- daemon/core/netns/vnode.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/daemon/core/netns/vnode.py b/daemon/core/netns/vnode.py index a874c692..a28ea5c4 100644 --- a/daemon/core/netns/vnode.py +++ b/daemon/core/netns/vnode.py @@ -2,6 +2,7 @@ PyCoreNode and LxcNode classes that implement the network namespac virtual node. """ +import errno import os import random import shutil @@ -145,10 +146,11 @@ class SimpleLxcNode(PyCoreNode): # remove node directory if present try: - if os.path.exists(self.ctrlchnlname): - os.unlink(self.ctrlchnlname) - except OSError: - logger.exception("error removing node directory") + os.unlink(self.ctrlchnlname) + except OSError as e: + # no such file or directory + if e.errno != errno.ENOENT: + logger.exception("error removing node directory") # clear interface data, close client, and mark self and not up self._netif.clear()