Which would at least fail if there is more than one BDM for a given volume, which we could use to detect if the volume we're attaching is multiattach=False, but that doesn't alleviate the race before the BDMs are created, it just makes the window a bit smaller.
I was wondering if a multiattach column on the bdm table could somehow be used as part of a constraint, but I don't think it would, because with a normal multiattach volume, we could have 2 BDMs for the same volume attached to two separate instances, and the multiattach value would be the same, so that's essentially the same as having a unique constraint on volume_id/instance_uuid.
So we have this query method:
https:/ /github. com/openstack/ nova/blob/ 0c441e636ba9d28 7909584b6ddf15e ab5d479f0e/ nova/objects/ block_device. py#L327
Which would at least fail if there is more than one BDM for a given volume, which we could use to detect if the volume we're attaching is multiattach=False, but that doesn't alleviate the race before the BDMs are created, it just makes the window a bit smaller.
I was wondering if a multiattach column on the bdm table could somehow be used as part of a constraint, but I don't think it would, because with a normal multiattach volume, we could have 2 BDMs for the same volume attached to two separate instances, and the multiattach value would be the same, so that's essentially the same as having a unique constraint on volume_ id/instance_ uuid.