From 1718bb38aa2c953f8a0175def29ec616122904d9 Mon Sep 17 00:00:00 2001 From: Bharat Kumar Date: Thu, 2 Apr 2015 15:31:36 +0530 Subject: [PATCH] CLOUDSTACK-8860: improve error messages in VM deployment code path. Conflicts: engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java --- .../api/command/user/vm/DeployVMCmd.java | 4 ++-- .../com/cloud/vm/VirtualMachineManagerImpl.java | 15 ++++++++------- server/src/com/cloud/vm/UserVmManagerImpl.java | 15 ++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index 77b10ec0684..cd949cd7faf 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -474,7 +474,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { response.setResponseName(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm uuid:"+getEntityUuid()); } } @@ -556,7 +556,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId); // Make sure a valid template ID was specified if (template == null) { - throw new InvalidParameterValueException("Unable to use template " + templateId); + throw new InvalidParameterValueException("Unable to find the template " + templateId); } DiskOffering diskOffering = null; diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 9dea90a41d1..d87150d3ea5 100644 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -985,7 +985,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { if (!changeState(vm, Event.OperationRetry, destHostId, work, Step.Prepare)) { - throw new ConcurrentOperationException("Unable to update the state of the Virtual Machine"); + throw new ConcurrentOperationException("Unable to update the state of the Virtual Machine "+vm.getUuid()+" oldstate: "+vm.getState()+ "Event :"+Event.OperationRetry); } } catch (final NoTransitionException e1) { throw new ConcurrentOperationException(e1.getMessage()); @@ -1036,7 +1036,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (host_guid != null) { final HostVO finalHost = _resourceMgr.findHostByGuid(host_guid); if (finalHost == null) { - throw new CloudRuntimeException("Host Guid " + host_guid + " doesn't exist in DB, something wrong here"); + throw new CloudRuntimeException("Host Guid " + host_guid + " doesn't exist in DB, something went wrong while processing start answer: "+startAnswer); } destHostId = finalHost.getId(); } @@ -1044,7 +1044,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac syncDiskChainChange(startAnswer); if (!changeState(vm, Event.OperationSucceeded, destHostId, work, Step.Done)) { - throw new ConcurrentOperationException("Unable to transition to a new state."); + s_logger.error("Unable to transition to a new state. VM uuid: "+vm.getUuid()+ "VM oldstate:"+vm.getState()+"Event:"+Event.OperationSucceeded); + throw new ConcurrentOperationException("Failed to deploy VM"+ vm.getUuid()); } // Update GPU device capacity @@ -1080,9 +1081,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (answer == null || !answer.getResult()) { s_logger.warn("Unable to stop " + vm + " due to " + (answer != null ? answer.getDetails() : "no answers")); _haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop); - throw new ExecutionException("Unable to stop " + vm + " so we are unable to retry the start operation"); + throw new ExecutionException("Unable to stop this VM, "+vm.getUuid()+" so we are unable to retry the start operation"); } - throw new ExecutionException("Unable to start " + vm + " due to error in finalizeStart, not retrying"); + throw new ExecutionException("Unable to start VM:"+vm.getUuid()+" due to error in finalizeStart, not retrying"); } } s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + (startAnswer == null ? " no start answer" : startAnswer.getDetails())); @@ -1090,8 +1091,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac break; } - } catch (final OperationTimedoutException e) { - s_logger.debug("Unable to send the start command to host " + dest.getHost()); + } catch (OperationTimedoutException e) { + s_logger.debug("Unable to send the start command to host " + dest.getHost()+" failed to start VM: "+vm.getUuid()); if (e.isActive()) { _haMgr.scheduleStop(vm, destHostId, WorkType.CheckStop); } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 97eceaf4b43..ecc2d6fe79d 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2692,7 +2692,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (networkIdList == null || networkIdList.isEmpty()) { Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId()); if (networkWithSecurityGroup == null) { - throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getId()); + throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getUuid()); } networkList.add(_networkDao.findById(networkWithSecurityGroup.getId())); @@ -3082,18 +3082,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), ntwkOffering.getTags(), ntwkOffering.getTrafficType()); if (physicalNetworkId == null) { - s_logger.warn("Network id " + network.getId() + " could not be streched to the zone " + zone.getId() - + " as valid phyical network could not be found"); throw new InvalidParameterValueException("Network in which is VM getting deployed could not be" + - " streched to the zone."); + " streched to the zone, as we could not find a valid physical network"); } String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(network.getId(), Service.Connectivity); if (!_networkModel.isProviderEnabledInPhysicalNetwork(physicalNetworkId, provider)) { - s_logger.warn("Network id " + network.getId() + " could not be streched to the zone " +zone.getId() - + " as Connectivity service provider is not enabled in the zone " + zone.getId()); throw new InvalidParameterValueException("Network in which is VM getting deployed could not be" + - " streched to the zone."); + " streched to the zone, as we could not find a valid physical network"); } } @@ -3488,7 +3484,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir UserVmVO tmpVm = _vmDao.findById(vm.getId()); if (!tmpVm.getState().equals(State.Running)) { // Some other thread changed state of VM, possibly vmsync - throw new ConcurrentOperationException("VM " + tmpVm + " unexpectedly went to " + tmpVm.getState() + " state"); + s_logger.error("VM " + tmpVm + " unexpectedly went to " + tmpVm.getState() + " state"); + throw new ConcurrentOperationException("Failed to deploy VM "+vm); } } finally { updateVmStateForFailedVmCreation(vm.getId(), hostId); @@ -3699,7 +3696,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // if account is removed, return error if (caller != null && caller.getRemoved() != null) { - throw new PermissionDeniedException("The account " + caller.getId() + " is removed"); + throw new PermissionDeniedException("The account " + caller.getUuid() + " is removed"); } UserVmVO vm = _vmDao.findById(vmId);