Skip to content

Commit 9be404a

Browse files
Likitha ShettyDaanHoogland
authored andcommitted
CLOUDSTACK-8107. Failed to create snapshot from volume when the task is performed repeatedly in zone wide primary Storage.
While taking a snapshot of a volume, CS chooses the endpoint to perform backup snapshot operation by selecting any host that has the storage containing the volume mounted on it. Instead, if the volume is attached to a VM, the endpoint chosen by CS should be the host that contains the VM. (cherry picked from commit a75a431)
1 parent 145b4a1 commit 9be404a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,21 @@ public EndPoint select(DataObject srcData, DataObject destData) {
215215
public EndPoint select(DataObject srcData, DataObject destData, StorageAction action) {
216216
if (action == StorageAction.BACKUPSNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
217217
SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;
218+
VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
219+
VirtualMachine vm = volumeInfo.getAttachedVM();
218220
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
219-
VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
220-
VirtualMachine vm = volumeInfo.getAttachedVM();
221221
if (vm != null && vm.getState() == VirtualMachine.State.Running) {
222222
return getEndPointFromHostId(vm.getHostId());
223223
}
224224
}
225+
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
226+
if (vm != null) {
227+
Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
228+
if (hostId != null) {
229+
return getEndPointFromHostId(hostId);
230+
}
231+
}
232+
}
225233
}
226234
return select(srcData, destData);
227235
}

0 commit comments

Comments
 (0)