Skip to content

Commit e2fc4ff

Browse files
Added missing lock
1 parent cae911a commit e2fc4ff

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,15 @@ private void createManagedVolumeCopyManagedTemplateAsyncWithLock(VolumeInfo volu
14971497
String tmplIdManagedPoolIdDestinationHostLockString = "tmplId:" + srcTemplateId + "managedPoolId:" + destDataStoreId + "destinationHostId:" + destHost.getId();
14981498
lock = GlobalLock.getInternLock(tmplIdManagedPoolIdDestinationHostLockString);
14991499
if (lock == null) {
1500-
throw new CloudRuntimeException("Unable to create managed storage template/volume, couldn't get global lock on " + tmplIdManagedPoolIdDestinationHostLockString);
1500+
throw new CloudRuntimeException("Unable to create volume from template, couldn't get global lock on " + tmplIdManagedPoolIdDestinationHostLockString);
15011501
}
1502+
1503+
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
1504+
if (!lock.lock(storagePoolMaxWaitSeconds)) {
1505+
s_logger.debug("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString);
1506+
throw new CloudRuntimeException("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString);
1507+
}
1508+
15021509
s_logger.debug("Copying the template to the volume on primary storage");
15031510
createManagedVolumeCopyManagedTemplateAsync(volumeInfo, destPrimaryDataStore, templateOnPrimary, destHost, future);
15041511
} finally {

0 commit comments

Comments
 (0)