mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
ff37fa5de0
commit
a75a431373
@ -205,13 +205,21 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
public EndPoint select(DataObject srcData, DataObject destData, StorageAction action) {
|
public EndPoint select(DataObject srcData, DataObject destData, StorageAction action) {
|
||||||
if (action == StorageAction.BACKUPSNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
|
if (action == StorageAction.BACKUPSNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||||
SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;
|
SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;
|
||||||
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
|
|
||||||
VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
|
VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
|
||||||
VirtualMachine vm = volumeInfo.getAttachedVM();
|
VirtualMachine vm = volumeInfo.getAttachedVM();
|
||||||
|
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
|
||||||
if (vm != null && vm.getState() == VirtualMachine.State.Running) {
|
if (vm != null && vm.getState() == VirtualMachine.State.Running) {
|
||||||
return getEndPointFromHostId(vm.getHostId());
|
return getEndPointFromHostId(vm.getHostId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
|
||||||
|
if (vm != null) {
|
||||||
|
Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
|
||||||
|
if (hostId != null) {
|
||||||
|
return getEndPointFromHostId(hostId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return select(srcData, destData);
|
return select(srcData, destData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user