From dc1556ca38300e2f34d7152d10db50c598917a01 Mon Sep 17 00:00:00 2001 From: Lucas Martins <56271185+lucas-a-martins@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:18:25 -0300 Subject: [PATCH] Change exception when orchestrating VM start (#9062) * Remove info about the environment from exception when starting VM * Change to log4j2 syntax --------- Co-authored-by: Lucas Martins --- .../main/java/com/cloud/vm/VirtualMachineManagerImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index d21e8b0fc7b..d207ebc41ce 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -95,6 +95,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.identity.ManagementServerNode; +import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; import org.apache.cloudstack.vm.UnmanagedVMsManager; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -5451,9 +5452,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner())); } catch (CloudRuntimeException e){ - String message = String.format("Unable to orchestrate start %s due to [%s].", vm.toString(), e.getMessage()); - logger.warn(message, e); - CloudRuntimeException ex = new CloudRuntimeException(message); + logger.error("Unable to orchestrate start {} due to [{}].", vm, e.getMessage()); + CloudRuntimeException ex = new CloudRuntimeException(String.format("Unable to orchestrate the start of VM instance %s.", + ReflectionToStringBuilderUtils.reflectOnlySelectedFields(vm, "instanceName", "uuid"))); return new Pair<>(JobInfo.Status.FAILED, JobSerializerHelper.toObjectSerializedString(ex)); } return new Pair<>(JobInfo.Status.SUCCEEDED, null);