From 64fef2e7f899199e83aa36aed73851bee081cf76 Mon Sep 17 00:00:00 2001 From: erikbocks Date: Sun, 15 Feb 2026 00:08:21 -0300 Subject: [PATCH 1/7] Change in exception message displayed when creating template from volume --- .../main/java/com/cloud/template/TemplateManagerImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 86bcb8a76d79..9eb40aded334 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -565,7 +565,8 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) { } if (imageStore == null) { - throw new CloudRuntimeException(String.format("Cannot find an image store for zone [%s].", zoneId)); + logger.error("Cannot find an image store for zone [{}].", zoneId); + throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator."); } return imageStore; @@ -2060,7 +2061,8 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t } DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId); if (store == null) { - throw new CloudRuntimeException("cannot find an image store for zone " + zoneId); + logger.error("Cannot find an image store for zone [{}].", zoneId); + throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator."); } AsyncCallFuture future; From 8deaffbe9fd773566d188ac86c1378fd3d1c8377 Mon Sep 17 00:00:00 2001 From: erikbocks Date: Tue, 17 Mar 2026 16:48:11 -0300 Subject: [PATCH 2/7] Address copilot's review for message change --- .../com/cloud/template/TemplateManagerImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 9eb40aded334..03b930cbd019 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -565,8 +565,7 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) { } if (imageStore == null) { - logger.error("Cannot find an image store for zone [{}].", zoneId); - throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator."); + throwExceptionForImageStoreObtentionFailure(zoneId, "upload volume"); } return imageStore; @@ -1748,7 +1747,7 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) { @Override @ActionEvent(eventType = EventTypes.EVENT_ISO_DELETE, eventDescription = "Deleting ISO", async = true) - public boolean deleteIso(DeleteIsoCmd cmd) { + public boolean deleteIso (DeleteIsoCmd cmd) { Long templateId = cmd.getId(); Account caller = CallContext.current().getCallingAccount(); Long zoneId = cmd.getZoneId(); @@ -2061,8 +2060,7 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t } DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId); if (store == null) { - logger.error("Cannot find an image store for zone [{}].", zoneId); - throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator."); + throwExceptionForImageStoreObtentionFailure(zoneId, "create template"); } AsyncCallFuture future; @@ -2919,4 +2917,9 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c return _tmpltDao.findById(template.getId()); } + + private void throwExceptionForImageStoreObtentionFailure(Long zoneId, String operation) { + logger.error("Cannot find an image store for zone [{}].", zoneId); + throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); + } } From 25e78e03c7feac0278f0c4f863e9570356173c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= <89930804+erikbocks@users.noreply.github.com> Date: Wed, 18 Mar 2026 08:13:50 -0300 Subject: [PATCH 3/7] Apply suggestion Co-authored-by: Suresh Kumar Anaparti --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 03b930cbd019..af99c73cdcc1 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1747,7 +1747,7 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) { @Override @ActionEvent(eventType = EventTypes.EVENT_ISO_DELETE, eventDescription = "Deleting ISO", async = true) - public boolean deleteIso (DeleteIsoCmd cmd) { + public boolean deleteIso(DeleteIsoCmd cmd) { Long templateId = cmd.getId(); Account caller = CallContext.current().getCallingAccount(); Long zoneId = cmd.getZoneId(); From 042f2bf2eefe52bf1cc6fb61560f171acc330c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= <89930804+erikbocks@users.noreply.github.com> Date: Wed, 9 Sep 2026 13:48:10 -0300 Subject: [PATCH 4/7] Enhance error logging for image store retrieval failure Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index af99c73cdcc1..ddd48f143cb2 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2919,7 +2919,7 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c } private void throwExceptionForImageStoreObtentionFailure(Long zoneId, String operation) { - logger.error("Cannot find an image store for zone [{}].", zoneId); + logger.error("Cannot find an image store for zone [{}] while trying to {}.", zoneId, operation); throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); } } From 384cf864f4bc5fffa486f7f0d95e774735587120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= Date: Thu, 12 Nov 2026 09:39:35 -0300 Subject: [PATCH 5/7] Make exception message more descriptive --- .../java/com/cloud/template/TemplateManagerImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index ddd48f143cb2..7f6c62b4f1b0 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -565,7 +565,7 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) { } if (imageStore == null) { - throwExceptionForImageStoreObtentionFailure(zoneId, "upload volume"); + throwExceptionForImageStoreRetrievalFailure(zoneId, "upload volume"); } return imageStore; @@ -2060,7 +2060,7 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t } DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId); if (store == null) { - throwExceptionForImageStoreObtentionFailure(zoneId, "create template"); + throwExceptionForImageStoreRetrievalFailure(zoneId, "create template"); } AsyncCallFuture future; @@ -2918,8 +2918,8 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c return _tmpltDao.findById(template.getId()); } - private void throwExceptionForImageStoreObtentionFailure(Long zoneId, String operation) { - logger.error("Cannot find an image store for zone [{}] while trying to {}.", zoneId, operation); - throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); + private void throwExceptionForImageStoreRetrievalFailure(Long zoneId, String operation) { + logger.error("Could not find an available image store to %s in zone [{}].", operation, zoneId); + throw new CloudRuntimeException(String.format("Failed to %s in zone %d because there was no available image storage.", operation, zoneId)); } } From 2699ee0a4d7c97927b53fa299ae2180b5c06737a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= Date: Wed, 2 Dec 2026 16:15:07 -0300 Subject: [PATCH 6/7] Remove zone ID from exception message --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 7f6c62b4f1b0..3ce2de1036d5 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2920,6 +2920,6 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c private void throwExceptionForImageStoreRetrievalFailure(Long zoneId, String operation) { logger.error("Could not find an available image store to %s in zone [{}].", operation, zoneId); - throw new CloudRuntimeException(String.format("Failed to %s in zone %d because there was no available image storage.", operation, zoneId)); + throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); } } From c81f5dfb5aad76e1eebd3f76c6ee148330f542e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20B=C3=B6ck?= Date: Wed, 2 Dec 2026 16:16:21 -0300 Subject: [PATCH 7/7] Fix parametrized log --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 3ce2de1036d5..32b465e8eaeb 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2919,7 +2919,7 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c } private void throwExceptionForImageStoreRetrievalFailure(Long zoneId, String operation) { - logger.error("Could not find an available image store to %s in zone [{}].", operation, zoneId); + logger.error("Could not find an available image store to {} in zone [{}].", operation, zoneId); throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); } }