Skip to content

Commit c569db7

Browse files
committed
hash-ring: Retry all DB operations if inactive
Neutron should be resilient to scenarios where connectivity to a service Neutron depends on is lost. SQL database is one of it and hash ring DB operations is used very early in the Neutron startup process. If the connection is lost right after new API worker was spawned then OVN IDLs are not instantiated and Neutron silently hangs on each request that uses OVN DB because the event signaling OVN is ready never happens. Closes-bug: #2029297 Change-Id: Id5bc24b76b7aa510d4066fbc5f7b8037cc8c740d Signed-off-by: Jakub Libosvar <[email protected]> (cherry picked from commit a505ff7)
1 parent 3944dff commit c569db7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

neutron/db/ovn_hash_ring_db.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
# NOTE(ralonsoh): this was migrated from networking-ovn to neutron and should
3131
# be refactored to be integrated in a OVO.
32+
@db_api.retry_if_session_inactive()
3233
def add_node(context, group_name, node_uuid=None):
3334
if node_uuid is None:
3435
node_uuid = uuidutils.generate_uuid()
@@ -41,6 +42,7 @@ def add_node(context, group_name, node_uuid=None):
4142
return node_uuid
4243

4344

45+
@db_api.retry_if_session_inactive()
4446
def remove_nodes_from_host(context, group_name):
4547
with db_api.CONTEXT_WRITER.using(context):
4648
context.session.query(ovn_models.OVNHashRing).filter(
@@ -50,13 +52,15 @@ def remove_nodes_from_host(context, group_name):
5052
CONF.host, group_name)
5153

5254

55+
@db_api.retry_if_session_inactive()
5356
def remove_node_by_uuid(context, node_uuid):
5457
with db_api.CONTEXT_WRITER.using(context):
5558
context.session.query(ovn_models.OVNHashRing).filter(
5659
ovn_models.OVNHashRing.node_uuid == node_uuid).delete()
5760
LOG.info('Node "%s" removed from the Hash Ring', node_uuid)
5861

5962

63+
@db_api.retry_if_session_inactive()
6064
def _touch(context, updated_at=None, **filter_args):
6165
if updated_at is None:
6266
updated_at = timeutils.utcnow()
@@ -90,19 +94,22 @@ def _get_nodes_query(context, interval, group_name, offline=False,
9094
return query
9195

9296

97+
@db_api.retry_if_session_inactive()
9398
@db_api.CONTEXT_READER
9499
def get_active_nodes(context, interval, group_name, from_host=False):
95100
query = _get_nodes_query(context, interval, group_name,
96101
from_host=from_host)
97102
return query.all()
98103

99104

105+
@db_api.retry_if_session_inactive()
100106
@db_api.CONTEXT_READER
101107
def count_offline_nodes(context, interval, group_name):
102108
query = _get_nodes_query(context, interval, group_name, offline=True)
103109
return query.count()
104110

105111

112+
@db_api.retry_if_session_inactive()
106113
@db_api.CONTEXT_READER
107114
def count_nodes_from_host(context, group_name):
108115
query = context.session.query(ovn_models.OVNHashRing).filter(

0 commit comments

Comments
 (0)