Skip to content

Commit 7a17cd1

Browse files
Dmitriy Rabotyagovpriteau
authored andcommitted
Respect passed arguments for Neutron client connection
At the moment quite vital arguments, such as region_name and valid_interfaces, are ignored by the plugin, which results in inconsistent behaviour with Octavia when trying to interact with Neutron. For instance, while Octavia connects to Neutron through the internal endpoint, the plugin still tries to reach it through the public one, ignoring options defined in [service_auth] and [neutron] sections. This patch is basically a copy-paste from Octavia [1]. [1] https://review.opendev.org/c/openstack/octavia/+/905794 Closes-Bug: #2110488 Related-Bug: #2049551 Change-Id: I3a98825e40143dfa9017ca512a27197c48c31ee9
1 parent 502c6d1 commit 7a17cd1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

ovn_octavia_provider/common/clients.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ def __init__(self):
118118
try:
119119
ksession = KeystoneSession('neutron')
120120

121-
kwargs = {}
121+
kwargs = {'region_name': CONF.neutron.region_name}
122+
try:
123+
interface = CONF.neutron.valid_interfaces[0]
124+
except (TypeError, LookupError):
125+
interface = CONF.neutron.valid_interfaces
126+
if interface:
127+
kwargs['interface'] = interface
122128
if CONF.neutron.endpoint_override:
123129
kwargs['network_endpoint_override'] = (
124130
CONF.neutron.endpoint_override)
125-
131+
if CONF.neutron.endpoint_override.startswith("https"):
132+
kwargs['insecure'] = CONF.neutron.insecure
133+
kwargs['cacert'] = CONF.neutron.cafile
126134
self.network_proxy = openstack.connection.Connection(
127135
session=ksession.session, **kwargs).network
128136
except Exception:

ovn_octavia_provider/tests/unit/common/test_clients.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class TestNeutronAuth(base.BaseTestCase):
9999
def setUp(self):
100100
super().setUp()
101101
config.register_opts()
102+
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
103+
self.conf.config(group='neutron', region_name='RegionOne',
104+
valid_interfaces='internal')
102105
self.mock_client = mock.patch(
103106
'openstack.connection.Connection').start()
104107
clients.Singleton._instances = {}
@@ -107,7 +110,8 @@ def setUp(self):
107110
def test_init(self, mock_ks):
108111
clients.NeutronAuth()
109112
self.mock_client.assert_called_once_with(
110-
session=mock_ks().session)
113+
session=mock_ks().session, interface='internal',
114+
region_name='RegionOne')
111115

112116
def test_singleton(self):
113117
c1 = clients.NeutronAuth()
@@ -133,7 +137,8 @@ def test_singleton_exception(self):
133137
def test_get_client(self, mock_ks):
134138
clients.get_neutron_client()
135139
self.mock_client.assert_called_once_with(
136-
session=mock_ks().session)
140+
session=mock_ks().session, interface='internal',
141+
region_name='RegionOne')
137142

138143
@mock.patch.object(clients, 'NeutronAuth', side_effect=[RuntimeError])
139144
def test_get_client_error(self, mock_ks):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
[`bug 2110488 <https://bugs.launchpad.net/neutron/+bug/2110488>`_]
5+
Fixed wrong endpoint information in Neutron client configuration.

0 commit comments

Comments
 (0)