This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new 21435590201 server: fix volume migration check for local volume attach
on a stopped (#9578)
21435590201 is described below
commit 21435590201bcb8ec819554682535037004ba37e
Author: Abhishek Kumar <[email protected]>
AuthorDate: Wed Sep 4 11:56:17 2024 +0530
server: fix volume migration check for local volume attach on a stopped
(#9578)
vm
Fixes #8645
When a local storage volume is being attached to a stopped VM, volume
migration is only needed when it is not present on the last host as the
current host ID will be null in the database.
Signed-off-by: Abhishek Kumar <[email protected]>
---
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
index e6092223f01..f52cd155142 100644
--- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
@@ -4312,7 +4312,11 @@ public class VolumeApiServiceImpl extends ManagerBase
implements VolumeApiServic
}
} else if (storeForNewStoreScope.getScopeType() == ScopeType.HOST
&& (storeForExistingStoreScope.getScopeType() ==
ScopeType.CLUSTER || storeForExistingStoreScope.getScopeType() ==
ScopeType.ZONE)) {
- Long hostId =
_vmInstanceDao.findById(existingVolume.getInstanceId()).getHostId();
+ VMInstanceVO vm =
_vmInstanceDao.findById(existingVolume.getInstanceId());
+ Long hostId = vm.getHostId();
+ if (hostId == null) {
+ hostId = vm.getLastHostId();
+ }
if (storeForNewStoreScope.getScopeId().equals(hostId)) {
return false;
}