winterhazel commented on code in PR #12296:
URL: https://github.com/apache/cloudstack/pull/12296#discussion_r2653584664
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/StorageOrchestrator.java:
##########
@@ -653,4 +674,51 @@ public TemplateApiResult call() {
return result;
}
}
+
+ private class CrossZoneCopyTemplateTask implements
Callable<TemplateApiResult> {
+ private final long userId;
+ private final TemplateInfo sourceTmpl;
+ private final DataStore sourceStore;
+ private final DataCenterVO dstZone;
+ private final String logid;
+
+ CrossZoneCopyTemplateTask(long userId,
+ TemplateInfo sourceTmpl,
+ DataStore sourceStore,
+ DataCenterVO dstZone) {
+ this.userId = userId;
+ this.sourceTmpl = sourceTmpl;
+ this.sourceStore = sourceStore;
+ this.dstZone = dstZone;
+ this.logid = ThreadContext.get(LOGCONTEXTID);
+ }
+
+ @Override
+ public TemplateApiResult call() {
+ ThreadContext.put(LOGCONTEXTID, logid);
+ TemplateApiResult result;
+ VMTemplateVO template = templateDao.findById(sourceTmpl.getId());
+ try {
+ boolean success = templateManager.copy(userId, template,
sourceStore, dstZone);
+
+ result = new TemplateApiResult(sourceTmpl);
+ if (!success) {
+ result.setResult("Cross-zone template copy failed");
+ }
+ } catch (Exception e) {
+ logger.error("Exception while copying template [{}] from zone
[{}] to zone [{}]",
+ template,
+ sourceStore.getScope().getScopeId(),
+ dstZone.getId(),
+ e);
+ result = new TemplateApiResult(sourceTmpl);
+ result.setResult(e.getMessage());
+ } finally {
+ tryCleaningUpExecutor(dstZone.getId());
+ ThreadContext.clearAll();
+ }
Review Comment:
Ah, that's better in fact. Could you also add the finally to
`CopyTemplateTask` and `MigrateDataTask`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]