From 63b5cfc14edaffaaef62a5cda2f63dfa907cb15b Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 7 Nov 2018 16:32:56 -0800 Subject: [PATCH] Fix VIP plug failure if netns directory exists In rare cases, the network namespace may already exist in the amphroa. VIP plug should not fail if the directory is already present. Change-Id: I33c2e1740bff1313ba6b8d3ef2ea4fe494263751 Story: 2004300 Task: 27856 --- octavia/amphorae/backends/agent/api_server/osutils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/octavia/amphorae/backends/agent/api_server/osutils.py b/octavia/amphorae/backends/agent/api_server/osutils.py index 6b6d7d8ffd..56d459b185 100644 --- a/octavia/amphorae/backends/agent/api_server/osutils.py +++ b/octavia/amphorae/backends/agent/api_server/osutils.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import ipaddress import os import shutil @@ -78,7 +79,13 @@ class BaseOS(object): # We need to setup the netns network directory so that the ifup # commands used here and in the startup scripts "sees" the right # interfaces and scripts. - os.makedirs('/etc/netns/' + consts.AMPHORA_NAMESPACE) + try: + os.makedirs('/etc/netns/' + consts.AMPHORA_NAMESPACE) + except OSError as e: + # Raise the error if it's not "File exists" otherwise pass + if e.errno != errno.EEXIST: + raise + shutil.copytree( network_dir, '/etc/netns/{netns}/{net_dir}'.format(