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.
Reviewed: https:/ /review. opendev. org/c/openstack /nova/+ /801990 /opendev. org/openstack/ nova/commit/ 2209b0007fe85d7 c5439e0bfdfe212 0c63898fa2
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit 2209b0007fe85d7 c5439e0bfdfe212 0c63898fa2
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
Change-Id: I92f35514efddcb