Generate version_id upon add_node
The version_id isn't set during add_node() call. This function is called when introspection starts for both "new" and existing node_info records. As a result, race conditions can appear in an HA inspector deployment (see the refered bug). This patch makes sure a version_id is generated during the add_node() call so stale record updates can be detected through the version_id mismatch between the inspector memory and the DB record. Change-Id: I422473e888e5e49abb3e598fc2cf2f330620bdcd Closes-Bug: #1719627
This commit is contained in:
parent
37b556ab7a
commit
82000e48ec
@ -686,9 +686,12 @@ def add_node(uuid, state, **attributes):
|
||||
started_at = timeutils.utcnow()
|
||||
with db.ensure_transaction() as session:
|
||||
_delete_node(uuid)
|
||||
db.Node(uuid=uuid, state=state, started_at=started_at).save(session)
|
||||
version_id = uuidutils.generate_uuid()
|
||||
db.Node(uuid=uuid, state=state, version_id=version_id,
|
||||
started_at=started_at).save(session)
|
||||
|
||||
node_info = NodeInfo(uuid=uuid, state=state, started_at=started_at,
|
||||
version_id=version_id,
|
||||
ironic=attributes.pop('ironic', None))
|
||||
for (name, value) in attributes.items():
|
||||
if not value:
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
A ``version_id`` is now explicitly generated during the
|
||||
``node_cache.start_introspection/.add_node`` call to avoid race conditions
|
||||
such as in case of the `two concurrent introspection calls bug`_.
|
||||
|
||||
.. _two concurrent introspection calls bug: https://bugs.launchpad.net/ironic-inspector/+bug/1719627
|
Loading…
Reference in New Issue
Block a user