Reuse _set_instances_share_data for replicas.
Replicas are just special instances after all, no need for duplicate code and missing on improvements like exception handling on NotFound error. Change-Id: I31fabebc6a60814a4cfc04ae0deb49dcb66cab0f Closes-Bug: #1923566 (cherry picked from commit29a943fde7
) (cherry picked from commit5bd8e46da5
) (cherry picked from commit1ae67eb0d6
) (cherry picked from commit6707ca7bcb
)
This commit is contained in:
parent
3a17dcbcf8
commit
cf9a6eb6c7
|
@ -1631,17 +1631,6 @@ def _share_replica_get_with_filters(context, share_id=None, replica_id=None,
|
||||||
return query
|
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
|
@require_context
|
||||||
def share_replicas_get_all(context, with_share_data=False,
|
def share_replicas_get_all(context, with_share_data=False,
|
||||||
with_share_server=True, session=None):
|
with_share_server=True, session=None):
|
||||||
|
@ -1652,7 +1641,7 @@ def share_replicas_get_all(context, with_share_data=False,
|
||||||
context, with_share_server=with_share_server, session=session).all()
|
context, with_share_server=with_share_server, session=session).all()
|
||||||
|
|
||||||
if with_share_data:
|
if with_share_data:
|
||||||
result = _set_replica_share_data(context, result, session)
|
result = _set_instances_share_data(context, result, session)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1669,7 +1658,7 @@ def share_replicas_get_all_by_share(context, share_id,
|
||||||
share_id=share_id, session=session).all()
|
share_id=share_id, session=session).all()
|
||||||
|
|
||||||
if with_share_data:
|
if with_share_data:
|
||||||
result = _set_replica_share_data(context, result, session)
|
result = _set_instances_share_data(context, result, session)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1688,7 +1677,7 @@ def share_replicas_get_available_active_replica(context, share_id,
|
||||||
status=constants.STATUS_AVAILABLE, session=session).first()
|
status=constants.STATUS_AVAILABLE, session=session).first()
|
||||||
|
|
||||||
if result and with_share_data:
|
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
|
return result
|
||||||
|
|
||||||
|
@ -1707,7 +1696,7 @@ def share_replica_get(context, replica_id, with_share_data=False,
|
||||||
raise exception.ShareReplicaNotFound(replica_id=replica_id)
|
raise exception.ShareReplicaNotFound(replica_id=replica_id)
|
||||||
|
|
||||||
if with_share_data:
|
if with_share_data:
|
||||||
result = _set_replica_share_data(context, result, session)[0]
|
result = _set_instances_share_data(context, result, session)[0]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1726,7 +1715,7 @@ def share_replica_update(context, share_replica_id, values,
|
||||||
context, share_replica_id, values, session=session)
|
context, share_replica_id, values, session=session)
|
||||||
|
|
||||||
if with_share_data:
|
if with_share_data:
|
||||||
updated_share_replica = _set_replica_share_data(
|
updated_share_replica = _set_instances_share_data(
|
||||||
context, updated_share_replica, session)[0]
|
context, updated_share_replica, session)[0]
|
||||||
|
|
||||||
return updated_share_replica
|
return updated_share_replica
|
||||||
|
|
|
@ -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…
Reference in New Issue