mike-tutkowski commented on a change in pull request #2298: CLOUDSTACK-9620:
Enhancements for managed storage
URL: https://github.com/apache/cloudstack/pull/2298#discussion_r161304423
##########
File path:
engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
##########
@@ -916,19 +1987,45 @@ else if (dataObj instanceof SnapshotInfo) {
throw new CloudRuntimeException("'dataObj' must be of type
'VolumeInfo' or 'SnapshotInfo'.");
}
- private CopyCmdAnswer performResignature(DataObject dataObj, HostVO
hostVO) {
- return performResignature(dataObj, hostVO, false);
+ private boolean isForVMware(DataObject dataObj) {
+ if (dataObj instanceof VolumeInfo) {
+ return ImageFormat.OVA.equals(((VolumeInfo)dataObj).getFormat());
+ }
+
+ if (dataObj instanceof SnapshotInfo) {
+ return
ImageFormat.OVA.equals(((SnapshotInfo)dataObj).getBaseVolume().getFormat());
+ }
+
+ return dataObj instanceof TemplateInfo &&
HypervisorType.VMware.equals(((TemplateInfo)dataObj).getHypervisorType());
+ }
+
+ private CopyCmdAnswer performResignature(DataObject dataObj, HostVO
hostVO, Map<String, String> extraDetails) {
+ return performResignature(dataObj, hostVO, extraDetails, false);
}
- private CopyCmdAnswer performResignature(DataObject dataObj, HostVO
hostVO, boolean keepGrantedAccess) {
+ private CopyCmdAnswer performResignature(DataObject dataObj, HostVO
hostVO, Map<String, String> extraDetails, boolean keepGrantedAccess) {
long storagePoolId = dataObj.getDataStore().getId();
DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId,
DataStoreRole.Primary);
Map<String, String> details = getDetails(dataObj);
+ if (extraDetails != null) {
+ details.putAll(extraDetails);
+ }
+
ResignatureCommand command = new ResignatureCommand(details);
- ResignatureAnswer answer = null;
+ ResignatureAnswer answer;
+
+ GlobalLock lock = GlobalLock.getInternLock(dataStore.getUuid());
+
+ if (!lock.lock(LOCK_TIME_IN_SECONDS)) {
+ String errMsg = "Couldn't lock the DB (in performResignature) on
the following string: " + dataStore.getUuid();
+
+ LOGGER.warn(errMsg);
+
+ throw new CloudRuntimeException(errMsg);
Review comment:
There are a couple reasons I believe CloudStack takes this approach:
1) Code was (every now and then) swallowing exceptions, so this at least
provides logging at the point where we convert from a checked exception to a
non-checked exception.
2) In some cases, the message of the exception is presented to the end user
and putting in a more readable string can help people. I went ahead and changed
the constructor that's used in several places to be
CloudRuntimeException(String message, Throwable t).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services