mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-2578: NPE in deleting template from S3.
This commit is contained in:
parent
cb0659ab33
commit
a4e6784e0b
@ -276,8 +276,9 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
// TODO: need to understand why we need to mark destroyed in
|
// TODO: need to understand why we need to mark destroyed in
|
||||||
// template_store_ref table here instead of in callback.
|
// template_store_ref table here instead of in callback.
|
||||||
// Currently I did that in callback, so I removed previous code to mark template_host_ref
|
// Currently I did that in callback, so I removed previous code to mark template_host_ref
|
||||||
|
if ( sZoneId != null ){
|
||||||
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
// get installpath of this template on image store
|
// get installpath of this template on image store
|
||||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||||
|
|||||||
@ -286,11 +286,10 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
eventType = EventTypes.EVENT_TEMPLATE_DELETE;
|
eventType = EventTypes.EVENT_TEMPLATE_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to understand why we need to mark destroyed in
|
if ( sZoneId != null ){
|
||||||
// template_store_ref table here instead of in callback.
|
//TODO: how to handle region wide usage data where sZoneId == null
|
||||||
// Currently I did that in callback, so I removed previous code to mark template_host_ref
|
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
||||||
|
}
|
||||||
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
|
||||||
|
|
||||||
List<UserVmJoinVO> userVmUsingIso = _userVmJoinDao.listActiveByIsoId(templateId);
|
List<UserVmJoinVO> userVmUsingIso = _userVmJoinDao.listActiveByIsoId(templateId);
|
||||||
// check if there is any VM using this ISO.
|
// check if there is any VM using this ISO.
|
||||||
|
|||||||
@ -281,8 +281,9 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
// TODO: need to understand why we need to mark destroyed in
|
// TODO: need to understand why we need to mark destroyed in
|
||||||
// template_store_ref table here instead of in callback.
|
// template_store_ref table here instead of in callback.
|
||||||
// Currently I did that in callback, so I removed previous code to mark template_host_ref
|
// Currently I did that in callback, so I removed previous code to mark template_host_ref
|
||||||
|
if (sZoneId != null){
|
||||||
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
List<UserVmJoinVO> userVmUsingIso = _userVmJoinDao.listActiveByIsoId(templateId);
|
List<UserVmJoinVO> userVmUsingIso = _userVmJoinDao.listActiveByIsoId(templateId);
|
||||||
// check if there is any VM using this ISO.
|
// check if there is any VM using this ISO.
|
||||||
|
|||||||
@ -1535,7 +1535,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
final String bucket = s3.getBucketName();
|
final String bucket = s3.getBucketName();
|
||||||
try {
|
try {
|
||||||
S3Utils.deleteDirectory(s3, bucket, path);
|
S3Utils.deleteDirectory(s3, bucket, path);
|
||||||
return new Answer(cmd, true, String.format("Deleted template %1%s from bucket %2$s.", path, bucket));
|
return new Answer(cmd, true, String.format("Deleted template %1$s from bucket %2$s.", path, bucket));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final String errorMessage = String.format("Failed to delete template %1$s from bucket %2$s due to the following error: %3$s", path,
|
final String errorMessage = String.format("Failed to delete template %1$s from bucket %2$s due to the following error: %3$s", path,
|
||||||
bucket, e.getMessage());
|
bucket, e.getMessage());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user