Repository navigation
CLOUDSTACK-8698: Retrieve a new device ID, if needed - #660
Conversation
|
cloudstack-pull-rats #216 SUCCESS |
|
cloudstack-pull-requests #913 SUCCESS |
|
cloudstack-pull-analysis #149 ABORTED |
|
LGTM @mike-tutkowski can this cause any side effect on any hypervisor/storage permutation? |
|
LGTM |
|
@bhaisaab I don't think there's any issue with the hypervisor matrix. What was happening was a NPE was being thrown in one scenario when trying to attach a volume to a stopped VM (regardless of hypervisor type, but in the case when the storage was not zone wide). Thanks! |
|
Even after e5ffcab and this change, race condition is possible right? Let us say the hypervisor takes time to attach and another attach command came in before this is completed. I think its better to persist the devidceId in the table(will set it back to null if something fails) as soon as we generate it and also synchronising the code in getDeviceId() function using GlobalLock |
|
I don't think there's a race condition anymore (it was fixed by my initial commit (not this code)). The attach code is run in serial for the VM in question. For example, if multiple attaches come in for the VM, they are serialized and so any race condition is avoided. The original problem was that the device ID was selected before passing the work to the job queue. If multiple attach commands came in simultaneously, we could pick the same device ID multiple times (so the second attach would fail). |
|
The reason we could pick multiple same device IDs is because the ID is not written to the DB until late in the attach process (after a successful attach on the hypervisor side). That being the case, if you started multiple attaches around the same time, they would pick up the same device ID and the second attach would fail. |
|
if we dont persist the deviceId at the time of generation, as you said multiple calls around the same time will still get the same id and the attach would fail (which would bring back the original problem). which is why I think, its better to persist the deviceId as soon as we generate and move the generation of deviceID logic to GlobalLlock. something like: |
|
So, the way we got around the issue of occasionally acquiring the same device ID was to move the retrieve-device-ID logic from the API layer (which can be called in parallel) to the attach logic in the job queue (which will serialize these kinds of calls to the same VM). In other words, we no longer have an issue of acquiring the same device ID. This particular bug is around us forgetting to call "acquire device ID" in the attach logic for one use case. |
|
ok. There are lot of ifs in that part of the code which makes it difficult to read. I will have to try it to understand fully for which I dont have time now. So, I would 👍 I will get back if I have any questions. |
|
Sounds good, @karuturi I'll go ahead and check the code in. Thanks for the comments. |
* pr/#660: CLOUDSTACK-8698: Retrieve a new device ID, if needed Signed-off-by: Mike Tutkowski (mike.tutkowski@solidfire.com) Signed-off-by: Mike Tutkowski <mike.tutkowski@solidfire.com>
This PR addresses https://issues.apache.org/jira/browse/CLOUDSTACK-8698.