These checks aren't necessary when triggered as part of a
network delete operation since any remaining subnets and ports
will be removed from the network. Additionally, they can race
with the auto cleanup methods for ports and subnets if segment
deletion is moved to BEFORE_DELETE where it should be.
Change-Id: I996f5b22f5179f5540760cc05c9f091bb3f3069b
This deprecates get_locked_port_and_binding and removes
its usage from ML2.
This function was misleading because it uses with_lockmode('update')
which does not actually block concurrent uses in galera multi-writer
deployments. A lock violation in multi-writer will manifest as a
deadlock at that end.
The revision service plugin already provides us with protection from
concurrent updates within a transaction via a compare and swap on the
revision number that will manifest as a staledataerror in races. This
error can then be retried by the retry decorator in the same way a
deadlock on multi-writer would.
This also will help us avoid trying to carry this db locking into
oslo versioned objects.
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: Id9f14db607cc5c6ca02293cb7e87bc1e68301808
For IPv6, the csnat port list could have multiple
subnets contained in it, but we were only ever
looking at the one associated with the first fixed
IP when trying to match an internal port. Change
to check all subnets on all port combinations
(internal and csnat) before giving up.
Change-Id: I9c0ac933c08734a3f6738a233fdf6021ce9bd375
Closes-bug: #1624515
We can retry _bind_port_if_needed safely since it
occurs outside of a transaction. There is no need to completely
destroy the port just for a binding deadlock retry.
TrivialFix
Change-Id: Ib4b98ebc0930032a8de0065a429730b7646a054d
With the callback system these tests can be simplified greatly.
Their heavy use of mocking has made them difficult to work with
and questionable in value.
These replacement tests are much shorter and verify the expected
transaction semantics without any mocking.
TrivialFix
Change-Id: If9612897cbde8fbe8aa8a19fc946b57e85290ce7
This relationship doesn't serve a purpose and it results
in SQLAlchemy trying to set the network_id column on ports
to NULL when attempting to delete a network with ports in it.
This results in the following exception:
IntegrityError: (1048, u"Column 'network_id' cannot be null")
This exception is not treated as a DBReferenceError by olso.db
which makes detecting races between ports being created on a
network being deleted very noisy in the logs since oslo.db treats
this as a generic DBError.
By removing the relationship, deleting a network will now just
result in a boring standard foreign key constraint failure which
will propagate from oslo.db as a DBReferenceError that is easy
to catch.
The patch that depends on this one adjusts the delete network logic
to capture these ReferenceErrors.
Change-Id: I4166a9bbaded57a77576400929a150123b8f1b2e
This switches to the use of subqueries for 1-m relationships
which will result in a higher constant query factor but will
eliminate the potential for cross-product explosions.
Closes-Bug: #1649317
Change-Id: I6952c48236153a8e2f2f155375b70573ddc2cf0f
Add support for oslo.db's DBError to is_nested_instance
so we can check for IntegrityErrors in DBErrors easily
that come back from oslo.db.
This will enable the patch that depends on this to detect
port creation/network delete races very easily and retry
them.
Change-Id: I617f2549caced6547d478caba968710ad8f913b3
This patch enhances the tag mechanism for subnet, port, subnetpool,
router resources. The tag-ext as new extension is added so that
tag supports their resources.
APIImpact: Adds tag support to subnet, port, subnetpool, router
DocImpact: allow users to set tags on some resources
Change-Id: I3ab8c2f47f283bee7219f39f20b07361b8e0c5f1
Closes-Bug: #1661608
This adjusts the ML2 dict extend functions to pass the
same session to the drivers that was used to generate
the sqlalchemy object that will be passed to them. This
will prevent reloading objects in a separate session that
can result in a performance hit or reads to an entirely
different server than the one that the object was generated
from.
Partially-Implements blueprint: enginefacade-switch
Change-Id: Id2dbb13e8aa5fcb86fab8e815033e57e6f0e98e8
The namespace proxy should only be handling config options passed in
via commandline. To achieve that it overwrites default config file
detection by explicitely passing in an empty list, however it did
not overwrite default config dir detection.
Starting with oslo.config 3.20.0, a default config_dir setting reads
files from $service.conf.d.
As Newton shipped with oslo.config 3.17, which did not expose this new
feature, this is a fix for Ocata only and does not affect Upgrade.
Change-Id: Id2dffe6f53afbfd48128d91c5d807be8785534eb
Closes-Bug: #1661106
This adjusts the batching logic in the Nova notifier to immediately
send and then sleep to allow batching of subsequent calls in the batch
interval.
So rather than always wait for 2 seconds to elapse while batching,
batching will only occur in the 2 second period after a call is made.
This turns the batch notifier into a standard queuing rate limiter.
The upside to this is a single port create results in an immediate
notification to Nova without a delay.
The downside is now that a sudden burst of 6 port creations to a
previously idle server will result in 2 notification calls to Nova
(1 for the first call and another for the other 5).
Closes-Bug: #1564648
Change-Id: I82f403441564955345f47877151e0c457712dd2f
This adds a service plugin to introduce random delays
and deadlocks to DB operations to make it easier for
us to see that retry decorators are correctly applied
and race conditions are handled.
Change-Id: I8e283c1b53165faee548d26b3560a2c883dfb977