Skip to content

Commit 4d333c9

Browse files
authored
Merge pull request #179 from stackhpc/upstream/2023.1-2024-09-23
Synchronise 2023.1 with upstream
2 parents ef1905f + f7d1df8 commit 4d333c9

File tree

9 files changed

+55
-10
lines changed

9 files changed

+55
-10
lines changed

neutron/notifiers/nova.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ def send_events(self, batched_events):
281281
try:
282282
response = novaclient.server_external_events.create(
283283
batched_events)
284+
except ks_exceptions.EndpointNotFound:
285+
LOG.exception("Nova endpoint not found, invalidating the session")
286+
self.session.invalidate()
284287
except nova_exceptions.NotFound:
285288
LOG.debug("Nova returned NotFound for event: %s",
286289
batched_events)

neutron/plugins/ml2/drivers/mech_sriov/agent/pci_lib.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ def set_vf_state(self, vf_index, state, auto=False):
7373
@param auto: set link_state to auto (0)
7474
"""
7575
ip = self.device(self.dev_name)
76-
if auto:
76+
# NOTE(ralonsoh): the state=False --> "disable" (2) has precedence over
77+
# "auto" (0) and "enable" (1).
78+
if state is False:
79+
link_state = 2
80+
elif auto:
7781
link_state = 0
7882
else:
79-
link_state = 1 if state else 2
83+
link_state = 1
8084
vf_config = {'vf': vf_index, 'link_state': link_state}
8185
ip.link.set_vf_feature(vf_config)
8286

neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import functools
2020
import multiprocessing
2121
import operator
22-
import signal
2322
import threading
2423
import types
2524
import uuid
@@ -43,6 +42,7 @@
4342
from oslo_config import cfg
4443
from oslo_db import exception as os_db_exc
4544
from oslo_log import log
45+
from oslo_service import service as oslo_service
4646
from oslo_utils import timeutils
4747
from ovsdbapp.backend.ovs_idl import idlutils
4848

@@ -312,8 +312,9 @@ def _setup_hash_ring(self):
312312
themselves to the hash ring.
313313
"""
314314
# Attempt to remove the node from the ring when the worker stops
315+
sh = oslo_service.SignalHandler()
315316
atexit.register(self._remove_node_from_hash_ring)
316-
signal.signal(signal.SIGTERM, self._remove_node_from_hash_ring)
317+
sh.add_handler("SIGTERM", self._remove_node_from_hash_ring)
317318

318319
admin_context = n_context.get_admin_context()
319320
if not self._hash_ring_probe_event.is_set():

neutron/plugins/ml2/ovo_rpc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import atexit
1515
import queue
16-
import signal
1716
import threading
1817
import traceback
1918
import weakref
@@ -24,6 +23,7 @@
2423
from neutron_lib import context as n_ctx
2524
from neutron_lib.db import api as db_api
2625
from oslo_log import log as logging
26+
from oslo_service import service
2727

2828
from neutron.api.rpc.callbacks import events as rpc_events
2929
from neutron.api.rpc.handlers import resources_rpc
@@ -38,8 +38,9 @@
3838

3939
def _setup_change_handlers_cleanup():
4040
atexit.register(_ObjectChangeHandler.clean_up)
41-
signal.signal(signal.SIGINT, _ObjectChangeHandler.clean_up)
42-
signal.signal(signal.SIGTERM, _ObjectChangeHandler.clean_up)
41+
sh = service.SignalHandler()
42+
sh.add_handler("SIGINT", _ObjectChangeHandler.clean_up)
43+
sh.add_handler("SIGTERM", _ObjectChangeHandler.clean_up)
4344

4445

4546
class _ObjectChangeHandler(object):

neutron/services/tag/tag_plugin.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ def __new__(cls, *args, **kwargs):
4747
def _extend_tags_dict(response_data, db_data):
4848
if not directory.get_plugin(tagging.TAG_PLUGIN_TYPE):
4949
return
50-
tags = [tag_db.tag for tag_db in db_data.standard_attr.tags]
50+
try:
51+
tags = [tag_db.tag for tag_db in db_data.standard_attr.tags]
52+
except AttributeError:
53+
# NOTE(ralonsoh): this method can be called from a "list"
54+
# operation. If one resource and its "standardattr" register is
55+
# deleted concurrently, the "standard_attr" field retrieval will
56+
# fail.
57+
# The "list" operation is protected with a READER transaction
58+
# context; however this is failing with the DB PostgreSQL backend.
59+
# https://bugs.launchpad.net/neutron/+bug/2078787
60+
tags = []
5161
response_data['tags'] = tags
5262

5363
@db_api.CONTEXT_READER

neutron/tests/unit/notifiers/test_nova.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ def test_no_notification_notify_nova_on_port_data_changes_false(self):
237237
{}, {})
238238
self.assertFalse(send_events.called)
239239

240+
@mock.patch('novaclient.client.Client')
241+
def test_nova_send_events_noendpoint_invalidate_session(self, mock_client):
242+
create = mock_client().server_external_events.create
243+
create.side_effect = ks_exc.EndpointNotFound
244+
with mock.patch.object(self.nova_notifier.session,
245+
'invalidate', return_value=True) as mock_sess:
246+
self.nova_notifier.send_events([])
247+
create.assert_called()
248+
mock_sess.assert_called()
249+
240250
@mock.patch('novaclient.client.Client')
241251
def test_nova_send_events_returns_bad_list(self, mock_client):
242252
create = mock_client().server_external_events.create

neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_pci_lib.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,29 @@ def test_get_vf_state_not_present(self):
6767
self.assertEqual(pci_lib.LinkState.disable.name, result)
6868

6969
def test_set_vf_state(self):
70+
# state=True, auto=False --> link_state=enable
7071
self.pci_wrapper.set_vf_state(self.VF_INDEX, True)
7172
vf = {'vf': self.VF_INDEX, 'link_state': 1}
7273
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
7374

75+
# state=False, auto=False --> link_state=disable
7476
self.mock_ip_device.link.set_vf_feature.reset_mock()
7577
self.pci_wrapper.set_vf_state(self.VF_INDEX, False)
7678
vf = {'vf': self.VF_INDEX, 'link_state': 2}
7779
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
7880

81+
# state=True, auto=True --> link_state=auto
7982
self.mock_ip_device.link.set_vf_feature.reset_mock()
80-
self.pci_wrapper.set_vf_state(self.VF_INDEX, False, auto=True)
83+
self.pci_wrapper.set_vf_state(self.VF_INDEX, True, auto=True)
8184
vf = {'vf': self.VF_INDEX, 'link_state': 0}
8285
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
8386

87+
# state=False, auto=True --> link_state=disable
88+
self.mock_ip_device.link.set_vf_feature.reset_mock()
89+
self.pci_wrapper.set_vf_state(self.VF_INDEX, False, auto=True)
90+
vf = {'vf': self.VF_INDEX, 'link_state': 2}
91+
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
92+
8493
def test_set_vf_spoofcheck(self):
8594
self.pci_wrapper.set_vf_spoofcheck(self.VF_INDEX, True)
8695
vf = {'vf': self.VF_INDEX, 'spoofchk': 1}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
security:
3+
- |
4+
A ML2/SR-IOV port with status=DOWN will always set the VF link state to
5+
"disable", regardless of the ``propagate_uplink_status`` port field value.
6+
The port disabling, to stop any transmission, has precedence over the
7+
link state "auto" value.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ oslo.privsep>=2.3.0 # Apache-2.0
4242
oslo.reports>=1.18.0 # Apache-2.0
4343
oslo.rootwrap>=5.15.0 # Apache-2.0
4444
oslo.serialization>=2.25.0 # Apache-2.0
45-
oslo.service>=2.8.0 # Apache-2.0
45+
oslo.service>=3.1.2 # Apache-2.0
4646
oslo.upgradecheck>=1.3.0 # Apache-2.0
4747
oslo.utils>=4.8.0 # Apache-2.0
4848
oslo.versionedobjects>=1.35.1 # Apache-2.0

0 commit comments

Comments
 (0)