Merge "Add comments for deletion of ARQs by instance or ARQ UUIDs."

This commit is contained in:
Zuul 2020-04-02 07:20:47 +00:00 committed by Gerrit Code Review
commit 754b24156d
2 changed files with 21 additions and 1 deletions

View File

@ -214,6 +214,14 @@ class ARQsController(base.CyborgController):
DELETE /v2/accelerator_requests?arqs=uuid1,uuid2,...
DELETE /v2/accelerator_requests?instance=uuid
The second form is idempotent, i.e., it would have the same effect
if called repeatedly with the same instance UUID. In other words,
it would not raise an error on the second and later attempts even if
the first one has deleted the ARQs. Whereas the first form is not
idempotent: if one or more of the ARQs do not exist, it would raise
an error. Nova uses the second form: so repeated calls do not cause
issues.
:param arq: List of ARQ UUIDs
:param instance: UUID of instance whose ARQs need to be deleted
"""

View File

@ -149,6 +149,12 @@ class ExtARQ(base.CyborgObject, object_base.VersionedObjectDictCompat,
@classmethod
def delete_by_uuid(cls, context, arq_uuid_list):
"""Delete a list of ARQs based on their UUIDs.
This is not idempotent, i.e., if the first call to delete an
ARQ has succeeded, second and later calls to delete the same ARQ
will get errored out.
"""
for uuid in arq_uuid_list:
obj_extarq = objects.ExtARQ.get(context, uuid)
# TODO() Defer deletion to conductor
@ -158,7 +164,13 @@ class ExtARQ(base.CyborgObject, object_base.VersionedObjectDictCompat,
@classmethod
def delete_by_instance(cls, context, instance_uuid):
"""Delete all ARQs for given instance."""
"""Delete all ARQs for given instance.
This is idempotent, i.e., it would have the same effect if called
repeatedly with the same instance UUID. In other words, it would
not raise an error on the second and later attempts even if the
first one has deleted the ARQs.
"""
obj_extarqs = [extarq for extarq in objects.ExtARQ.list(context)
if extarq.arq['instance_uuid'] == instance_uuid]
for obj_extarq in obj_extarqs: