Browse Source

Merge "Reuse _set_instances_share_data for replicas." into stable/wallaby

stable/wallaby
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
8de6a20379
2 changed files with 10 additions and 16 deletions
  1. +5
    -16
      manila/db/sqlalchemy/api.py
  2. +5
    -0
      releasenotes/notes/bug-1923566-fix-notfound-replica-parent-share-d8e50659c02b941a.yaml

+ 5
- 16
manila/db/sqlalchemy/api.py View File

@ -1822,17 +1822,6 @@ def _share_replica_get_with_filters(context, share_id=None, replica_id=None,
return query
def _set_replica_share_data(context, replicas, session):
if replicas and not isinstance(replicas, list):
replicas = [replicas]
for replica in replicas:
parent_share = share_get(context, replica['share_id'], session=session)
replica.set_share_data(parent_share)
return replicas
@require_context
def share_replicas_get_all(context, with_share_data=False,
with_share_server=True, session=None):
@ -1843,7 +1832,7 @@ def share_replicas_get_all(context, with_share_data=False,
context, with_share_server=with_share_server, session=session).all()
if with_share_data:
result = _set_replica_share_data(context, result, session)
result = _set_instances_share_data(context, result, session)
return result
@ -1860,7 +1849,7 @@ def share_replicas_get_all_by_share(context, share_id,
share_id=share_id, session=session).all()
if with_share_data:
result = _set_replica_share_data(context, result, session)
result = _set_instances_share_data(context, result, session)
return result
@ -1879,7 +1868,7 @@ def share_replicas_get_available_active_replica(context, share_id,
status=constants.STATUS_AVAILABLE, session=session).first()
if result and with_share_data:
result = _set_replica_share_data(context, result, session)[0]
result = _set_instances_share_data(context, result, session)[0]
return result
@ -1898,7 +1887,7 @@ def share_replica_get(context, replica_id, with_share_data=False,
raise exception.ShareReplicaNotFound(replica_id=replica_id)
if with_share_data:
result = _set_replica_share_data(context, result, session)[0]
result = _set_instances_share_data(context, result, session)[0]
return result
@ -1917,7 +1906,7 @@ def share_replica_update(context, share_replica_id, values,
context, share_replica_id, values, session=session)
if with_share_data:
updated_share_replica = _set_replica_share_data(
updated_share_replica = _set_instances_share_data(
context, updated_share_replica, session)[0]
return updated_share_replica


+ 5
- 0
releasenotes/notes/bug-1923566-fix-notfound-replica-parent-share-d8e50659c02b941a.yaml View File

@ -0,0 +1,5 @@
---
fixes:
- Fixed NotFound error in share replica periodic tasks. It could happen that
the parent share of the replica that was being worked on had already been
deleted.

Loading…
Cancel
Save