compute: Avoid duplicate BDMs during reserve_block_device_name
When attaching a volume to a running instance the nova-api validates
that the volume is not already attached to the instance. However
nova-compute is responsible for actually creating the BDM entry in the
database. If sending attach requests fast enough it can be possible
that the same "attach_volume" request can be sent to nova-compute for
the same volume/instance combination.
To work around this we add a check in nova-compute to validate that
the volume has not been attached in the mean time.
Closes-Bug: #1937375
Change-Id: I92f35514efddcb071c7094370b79d91d34c5bc72
(cherry picked from commit 2209b0007fe85d7c5439e0bfdfe2120c63898fa2)
Reviewed: https:/ /review. opendev. org/c/openstack /nova/+ /803718 /opendev. org/openstack/ nova/commit/ 2bee83b8a980b2b d9e276b75aa7425 3f8c0d0a70
Committed: https:/
Submitter: "Zuul (22348)"
Branch: stable/wallaby
commit 2bee83b8a980b2b d9e276b75aa7425 3f8c0d0a70
Author: Felix Huettner <email address hidden>
Date: Fri Jul 23 10:43:32 2021 +0200
compute: Avoid duplicate BDMs during reserve_ block_device_ name
When attaching a volume to a running instance the nova-api validates
that the volume is not already attached to the instance. However
nova-compute is responsible for actually creating the BDM entry in the
database. If sending attach requests fast enough it can be possible
that the same "attach_volume" request can be sent to nova-compute for
the same volume/instance combination.
To work around this we add a check in nova-compute to validate that
the volume has not been attached in the mean time.
Closes-Bug: #1937375 071c7094370b79d 91d34c5bc72 c5439e0bfdfe212 0c63898fa2)
Change-Id: I92f35514efddcb
(cherry picked from commit 2209b0007fe85d7