Before 46d44cf3b, it was technically possible to assign a monitor
condition directly to Idl.tables[table_name].condition. If done
before the connection was established, it would successfully apply
the condition (where cond_change() actually would fail).

Although this wasn't meant to be supported, several OpenStack
projects made use of this. After 46d44cf3b, .condition is no
longer a list, but a ConditionState. Assigning a list to it breaks
the Idl.

The Neutron and ovsdbapp projects have patches in-flight to
use Idl.cond_change() if ConditionState exists, as it now works
before connection as well. There could be other users that also
start failing when upgrading to OVS 2.17, so this patch makes
TableSchema.condition a property, warning users who assign to
.condition to use cond_change() instead, but doing the equivalent
to what it used to do.

Fixes: 46d44cf3b ("python: idl: Add monitor_cond_since support")
Signed-off-by: Terry Wilson <twil...@redhat.com>
---
 python/ovs/db/idl.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 83a634dd0..1f75e9d8e 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -140,6 +140,21 @@ class ConditionState(object):
         return False
 
 
+def get_condition(self):
+    return self._condition
+
+
+def set_condition(self, condition):
+    if isinstance(condition, ConditionState):
+        self._condition = condition
+    else:
+        vlog.warn("Setting table.condition directly is unsupported! "
+                  "Use Idl.cond_change() instead.")
+        if not hasattr(self, '_condition'):
+            self._condition = ConditionState()
+        self.idl.cond_change(self.name, condition)
+
+
 class Idl(object):
     """Open vSwitch Database Interface Definition Language (OVSDB IDL).
 
@@ -205,6 +220,9 @@ class Idl(object):
         Monitor.monitor_cond: IDL_S_DATA_MONITOR_COND_REQUESTED,
         Monitor.monitor_cond_since: IDL_S_DATA_MONITOR_COND_SINCE_REQUESTED}
 
+    ovs.db.schema.TableSchema.condition = property(get_condition,
+                                                   set_condition)
+
     def __init__(self, remote, schema_helper, probe_interval=None,
                  leader_only=True):
         """Creates and returns a connection to the database named 'db_name' on
-- 
2.34.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to