Refresh volume when checking for conflicting attachments
We should only be able to create more than one attachment to the
same volume if it's (1) multiattach=True or (2) it's multiattach=False
AND the attachments are to the same instance. It is not valid to
attach more than one instance to the same multiattach=False volume.
The _attachment_reserve method is checking for this if the
conditional update to the volume status fails, but it does
not refresh the volume before checking the attachments. Since
we could be racing to create attachments concurrently, when
the request that failed the conditional update actually pulled
the volume out of the DB, it might not have had any attachments,
so we need to refresh it before checking the list of attachments
to see if the instance we're trying to attach (reserve the volume)
is the same as what's already attached to the volume.
Reviewed: https:/ /review. openstack. org/560074 /git.openstack. org/cgit/ openstack/ cinder/ commit/ ?id=dd93b0c7190 681620c3eed9937 462901da42c7c4
Committed: https:/
Submitter: Zuul
Branch: master
commit dd93b0c71906816 20c3eed99374629 01da42c7c4
Author: Matt Riedemann <email address hidden>
Date: Tue Apr 10 12:28:05 2018 -0400
Refresh volume when checking for conflicting attachments
We should only be able to create more than one attachment to the
same volume if it's (1) multiattach=True or (2) it's multiattach=False
AND the attachments are to the same instance. It is not valid to
attach more than one instance to the same multiattach=False volume.
The _attachment_reserve method is checking for this if the
conditional update to the volume status fails, but it does
not refresh the volume before checking the attachments. Since
we could be racing to create attachments concurrently, when
the request that failed the conditional update actually pulled
the volume out of the DB, it might not have had any attachments,
so we need to refresh it before checking the list of attachments
to see if the instance we're trying to attach (reserve the volume)
is the same as what's already attached to the volume.
Change-Id: Iee78555163bbcb b5ff3e0ba008d7c 87a3aedfb0f
Closes-Bug: #1762687