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 <a.zaikin@partner.samsung.com>
This commit is contained in:
Andrey Zaikin 2020-02-28 17:40:22 +03:00
parent 25fb761251
commit 172b2562bb
2 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,8 @@
# under the License. # under the License.
import os
from kuryr.lib._i18n import _ from kuryr.lib._i18n import _
from kuryr.lib.binding.drivers import utils as kl_utils from kuryr.lib.binding.drivers import utils as kl_utils
from kuryr.lib import constants as kl_const 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: if not vhostuser_mount_point:
raise oslo_cfg.RequiredOptError('vhostuser_mount_point', raise oslo_cfg.RequiredOptError('vhostuser_mount_point',
'neutron_defaults') 'neutron_defaults')
vif_name = _get_vhu_vif_name(os_port.id)
vif = osv_vif.VIFVHostUser( vif = osv_vif.VIFVHostUser(
id=os_port.id, id=os_port.id,
address=os_port.mac_address, 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), active=_is_port_active(os_port),
port_profile=profile, port_profile=profile,
plugin='ovs', plugin='ovs',
path=vhostuser_mount_point, path=os.path.join(vhostuser_mount_point, vif_name),
mode=vhostuser_mode, mode=vhostuser_mode,
vif_name=_get_vhu_vif_name(os_port.id), vif_name=vif_name,
bridge_name=network.bridge) bridge_name=network.bridge)
elif details.get('ovs_hybrid_plug'): elif details.get('ovs_hybrid_plug'):
vif = osv_vif.VIFBridge( vif = osv_vif.VIFBridge(

View File

@ -321,7 +321,7 @@ class TestOSVIFUtils(test_base.TestCase):
port_profile = mock.sentinel.port_profile port_profile = mock.sentinel.port_profile
network = mock.sentinel.network network = mock.sentinel.network
port_active = mock.sentinel.port_active port_active = mock.sentinel.port_active
vif_name = mock.sentinel.vif_name vif_name = "vhu01234567-89"
vif = mock.sentinel.vif vif = mock.sentinel.vif
m_mk_profile.return_value = port_profile m_mk_profile.return_value = port_profile