Remove oslo_utils dependency
Remove oslo_utils which was used for save_and_reraise exception. In this process, I noticed that if retry=False in get_schema_helper, it would retry anyay, so that bug is fixed as well. The try_add_manager attribute was added to get_schema_helper to support use cases like OVN's where ovs-vsctl may not be installed on a machine.
This commit is contained in:
parent
e0012e70bd
commit
08db3574aa
@ -16,7 +16,6 @@ import logging
|
||||
import time
|
||||
|
||||
from ovsdbapp import exceptions
|
||||
from oslo_utils import excutils
|
||||
from ovs.db import idl
|
||||
from six.moves import queue as Queue
|
||||
|
||||
@ -96,10 +95,9 @@ class Transaction(api.Transaction):
|
||||
try:
|
||||
command.run_idl(txn)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception() as ctx:
|
||||
txn.abort()
|
||||
if not self.check_error:
|
||||
ctx.reraise = False
|
||||
txn.abort()
|
||||
if self.check_error:
|
||||
raise
|
||||
seqno = self.api.idl.change_seqno
|
||||
status = txn.commit_block()
|
||||
if status == txn.TRY_AGAIN:
|
||||
|
@ -15,7 +15,6 @@
|
||||
import collections
|
||||
import logging
|
||||
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
|
||||
from ovsdbapp import api
|
||||
@ -35,11 +34,10 @@ class BaseCommand(api.Command):
|
||||
txn.add(self)
|
||||
return self.result
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception() as ctx:
|
||||
if log_errors:
|
||||
LOG.exception("Error executing command")
|
||||
if not check_error:
|
||||
ctx.reraise = False
|
||||
if log_errors:
|
||||
LOG.exception("Error executing command")
|
||||
if check_error:
|
||||
raise
|
||||
|
||||
def post_commit(self, txn):
|
||||
pass
|
||||
|
@ -18,7 +18,6 @@ import time
|
||||
import uuid
|
||||
|
||||
from ovsdbapp import exceptions
|
||||
from oslo_utils import excutils
|
||||
from ovs.db import idl
|
||||
from ovs import jsonrpc
|
||||
from ovs import poller
|
||||
@ -117,24 +116,25 @@ def _get_schema_helper(connection, schema_name):
|
||||
return idl.SchemaHelper(None, resp.result)
|
||||
|
||||
|
||||
def get_schema_helper(connection, schema_name, retry=True):
|
||||
def get_schema_helper(connection, schema_name,
|
||||
retry=True, try_add_manager=True):
|
||||
try:
|
||||
return _get_schema_helper(connection, schema_name)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception(reraise=False) as ctx:
|
||||
if not retry:
|
||||
ctx.reraise = True
|
||||
# We may have failed due to set-manager not being called
|
||||
if not retry:
|
||||
raise
|
||||
# We may have failed due to set-manager not being called
|
||||
if try_add_manager:
|
||||
helpers.enable_connection_uri(connection)
|
||||
|
||||
# There is a small window for a race, so retry up to a second
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=0.01),
|
||||
stop=tenacity.stop_after_delay(1),
|
||||
reraise=True)
|
||||
def do_get_schema_helper():
|
||||
return _get_schema_helper(connection, schema_name)
|
||||
# There is a small window for a race, so retry up to a second
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=0.01),
|
||||
stop=tenacity.stop_after_delay(1),
|
||||
reraise=True)
|
||||
def do_get_schema_helper():
|
||||
return _get_schema_helper(connection, schema_name)
|
||||
|
||||
return do_get_schema_helper()
|
||||
return do_get_schema_helper()
|
||||
|
||||
|
||||
def wait_for_change(_idl, timeout, seqno=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user