From 172b2562bb8d02dd23430e668780fa62df5438fc Mon Sep 17 00:00:00 2001 From: Andrey Zaikin Date: Fri, 28 Feb 2020 17:40:22 +0300 Subject: [PATCH] Autogenerate path for vhostuserclient socket Before this patch path to a vhostuserclient socket was hardcodeed in a kuryr-kubernetes config file. So every new created port was using the same path. That leaded to a socket-file conflict when more than one container was intended to use a DPDK-enabled port. This patch automatically concatenates portname to a socket directory path, so every port gets a unique vhost-server-path like "/var/run/vhostuser/vhua5a8d6c0-41" Change-Id: I9112365585466a126e2653f25aea71ff473c86b8 Signed-off-by: Andrey Zaikin --- kuryr_kubernetes/os_vif_util.py | 7 +++++-- kuryr_kubernetes/tests/unit/test_os_vif_util.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kuryr_kubernetes/os_vif_util.py b/kuryr_kubernetes/os_vif_util.py index 97b610acb..9f16492e7 100644 --- a/kuryr_kubernetes/os_vif_util.py +++ b/kuryr_kubernetes/os_vif_util.py @@ -14,6 +14,8 @@ # under the License. +import os + from kuryr.lib._i18n import _ from kuryr.lib.binding.drivers import utils as kl_utils from kuryr.lib import constants as kl_const @@ -272,6 +274,7 @@ def neutron_to_osvif_vif_ovs(vif_plugin, os_port, subnets): if not vhostuser_mount_point: raise oslo_cfg.RequiredOptError('vhostuser_mount_point', 'neutron_defaults') + vif_name = _get_vhu_vif_name(os_port.id) vif = osv_vif.VIFVHostUser( id=os_port.id, address=os_port.mac_address, @@ -281,9 +284,9 @@ def neutron_to_osvif_vif_ovs(vif_plugin, os_port, subnets): active=_is_port_active(os_port), port_profile=profile, plugin='ovs', - path=vhostuser_mount_point, + path=os.path.join(vhostuser_mount_point, vif_name), mode=vhostuser_mode, - vif_name=_get_vhu_vif_name(os_port.id), + vif_name=vif_name, bridge_name=network.bridge) elif details.get('ovs_hybrid_plug'): vif = osv_vif.VIFBridge( diff --git a/kuryr_kubernetes/tests/unit/test_os_vif_util.py b/kuryr_kubernetes/tests/unit/test_os_vif_util.py index 9138a39a7..b3262cd00 100644 --- a/kuryr_kubernetes/tests/unit/test_os_vif_util.py +++ b/kuryr_kubernetes/tests/unit/test_os_vif_util.py @@ -321,7 +321,7 @@ class TestOSVIFUtils(test_base.TestCase): port_profile = mock.sentinel.port_profile network = mock.sentinel.network port_active = mock.sentinel.port_active - vif_name = mock.sentinel.vif_name + vif_name = "vhu01234567-89" vif = mock.sentinel.vif m_mk_profile.return_value = port_profile