Skip to content

Commit ef99f01

Browse files
committed
Merge remote-tracking branch 'anshul/CLOUDSTACK-6900'
This closes apache#68 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 085554d + 91e1881 commit ef99f01

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,29 @@ public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId) {
206206
sc.setParameters("store_id", storeId);
207207
sc.setParameters("volume_id", volumeId);
208208
sc.setParameters("destroyed", false);
209-
return findOneBy(sc);
209+
210+
/*
211+
When we download volume then we create entry in volume_store_ref table.
212+
We mark the volume entry to ready state once download_url gets generated.
213+
When we migrate that volume, then again one more entry is created with same volume id.
214+
Its state is marked as allocated. Later we try to list only one dataobject in datastore
215+
for state transition during volume migration. If the listed volume's state is allocated
216+
then migration passes otherwise it fails.
217+
218+
Below fix will remove the randomness and give priority to volume entry which is made for
219+
migration (download_url/extracturl will be null in case of migration). Giving priority to
220+
download volume case is not needed as there will be only one entry in that case so no randomness.
221+
*/
222+
List<VolumeDataStoreVO> vos = listBy(sc);
223+
if(vos.size() > 1) {
224+
for(VolumeDataStoreVO vo : vos) {
225+
if(vo.getExtractUrl() == null) {
226+
return vo;
227+
}
228+
}
229+
}
230+
231+
return vos.size() == 1 ? vos.get(0) : null;
210232
}
211233

212234
@Override

0 commit comments

Comments
 (0)