From 91e1881be82b06963903b7ee6aa15cdbcc04705f Mon Sep 17 00:00:00 2001 From: Anshul Gangwar Date: Tue, 13 Jan 2015 16:35:10 +0530 Subject: [PATCH] CLOUDSTACK-6900: This fixes volume migration failing after that volume is downloaded. When we download volume then we create entry in volume_store_ref table. We mark the volume entry to ready state once download_url gets generated. When we migrate that volume, then again one more entry is created with same volume id. Its state is marked as allocated. Later we try to list only one dataobject in datastore for state transition during volume migration. If the listed volume's state is allocated then migration passes otherwise it fails. Below fix will remove the randomness and give priority to volume entry which is made for migration (download_url/extracturl will be null in case of migration). Giving priority to download volume case is not needed as there will be only one entry in that case so no randomness. --- .../image/db/VolumeDataStoreDaoImpl.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java index b71eb2c2324..1f6068057fe 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java @@ -206,7 +206,29 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase vos = listBy(sc); + if(vos.size() > 1) { + for(VolumeDataStoreVO vo : vos) { + if(vo.getExtractUrl() == null) { + return vo; + } + } + } + + return vos.size() == 1 ? vos.get(0) : null; } @Override