DaanHoogland commented on code in PR #14401:
URL: https://github.com/apache/cloudstack/pull/14401#discussion_r4323464810
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -3559,6 +3559,12 @@ private Volume orchestrateDetachVolumeFromVM(long vmId,
long volumeId) {
Volume volume = _volsDao.findById(volumeId);
VMInstanceVO vm = _vmInstanceDao.findById(vmId);
+ // A queued detach can run after the volume was already detached and
attached elsewhere; leave that attachment alone
+ if (volume.getInstanceId() == null || volume.getInstanceId() != vmId) {
+ logger.warn("Volume {} is no longer attached to VM {}, skipping
detach", volume, vm);
+ return volume;
+ }
+
Review Comment:
does what it should, just one cleanup suggestion; add a
`shouldDetachBeSkipped(Volume voume, VMInstanceVO vm)` and make the comment a
javadoc. Then return the volume on true.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]