summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Wilson <twilson@redhat.com>2022-03-22 04:12:08 +0000
committerTerry Wilson <twilson@redhat.com>2022-04-22 14:14:45 +0000
commit37c2e6b708678d2e648f111d102b6394f4e704b0 (patch)
treeff92e7eb14931e85a2aec0402e85f7cae091d9b3
parent4070861450cc8f8ec85256fa4bac9b5b3aaa0e3f (diff)
downloadneutron-37c2e6b708678d2e648f111d102b6394f4e704b0.tar.gz
Fix setting table monitoring conditionsvictoria-em17.4.1
After the monitor_cond_since/update3 support patch in ovs (46d44cf3be0), directly setting table.condition is broken. This isn't something that was every truly supported. Prior to that patch, using Idl.cond_change() before a connection was made did not work, but after that patch it does. This patch uses the old behavior when the OVS library does not have the ConditionState object, and uses cond_change() otherwise. Related-Bug: #1965819 Change-Id: I0503037b803a3c99fb7988bc20394c111ac456db (cherry picked from commit a13a4cb2da03e2cdce04b0e7b4bc30e44ebdbd02)
-rw-r--r--neutron/agent/ovn/metadata/ovsdb.py2
-rw-r--r--neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py17
2 files changed, 13 insertions, 6 deletions
diff --git a/neutron/agent/ovn/metadata/ovsdb.py b/neutron/agent/ovn/metadata/ovsdb.py
index 18d9812f92..7817bdaf85 100644
--- a/neutron/agent/ovn/metadata/ovsdb.py
+++ b/neutron/agent/ovn/metadata/ovsdb.py
@@ -50,7 +50,7 @@ class MetadataAgentOvnSbIdl(ovsdb_monitor.OvnIdl):
if chassis:
for table in set(tables).intersection({'Chassis',
'Chassis_Private'}):
- self.tables[table].condition = [['name', '==', chassis]]
+ self.set_table_condition(table, [['name', '==', chassis]])
if events:
self.notify_handler.watch_events(events)
diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py
index f09ab6b3f6..c8a828a401 100644
--- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py
+++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py
@@ -23,6 +23,7 @@ from neutron_lib.utils import helpers
from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
+from ovs.db import idl as ovs_idl_mod
from ovs.stream import Stream
from ovsdbapp.backend.ovs_idl import connection
from ovsdbapp.backend.ovs_idl import event as row_event
@@ -456,6 +457,15 @@ class Ml2OvnIdlBase(connection.OvsdbIdl):
super(Ml2OvnIdlBase, self).__init__(
remote, schema, probe_interval=probe_interval, **kwargs)
+ def set_table_condition(self, table_name, condition):
+ # Prior to ovs commit 46d44cf3be0, self.cond_change() doesn't work here
+ # but after that commit, setting table.condtion doesn't work.
+ if hasattr(ovs_idl_mod, 'ConditionState'):
+ self.cond_change(table_name, condition)
+ else:
+ # Can be removed after the minimum ovs version >= 2.17.0
+ self.tables[table_name].condition = condition
+
class BaseOvnIdl(Ml2OvnIdlBase):
def __init__(self, remote, schema, **kwargs):
@@ -668,11 +678,8 @@ class OvnInitPGNbIdl(OvnIdl):
def __init__(self, driver, remote, schema):
super(OvnInitPGNbIdl, self).__init__(driver, remote, schema)
- # self.cond_change() doesn't work here because we are setting the
- # condition *before an initial monitor request is made* so there is
- # no previous session whose condition we wish to change
- self.tables['Port_Group'].condition = [
- ['name', '==', ovn_const.OVN_DROP_PORT_GROUP_NAME]]
+ self.set_table_condition(
+ 'Port_Group', [['name', '==', ovn_const.OVN_DROP_PORT_GROUP_NAME]])
self.neutron_pg_drop_event = NeutronPgDropPortGroupCreated()
self.notify_handler.watch_event(self.neutron_pg_drop_event)