From 80a328034cc788ca486d5f5eab9e9b364b158afc Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 16 Feb 2011 14:17:56 -0800 Subject: [PATCH] bug 8609: when failed to start a VM in HA (due to domr is not migrated), a runtimeException is thrown out, caused HA for this VM is not resheduced. status 8609: resolved fixed --- .../com/cloud/ha/HighAvailabilityManagerImpl.java | 13 +++++-------- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 10 +++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java index 127347f3cc8..e0693663711 100644 --- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -446,27 +446,24 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu if (s_logger.isDebugEnabled()) { s_logger.debug("Rescheduling VM " + vm.toString() + " to try again in " + _restartRetryInterval); } - vm = _itMgr.findById(vm.getType(), vm.getId()); - work.setUpdateTime(vm.getUpdated()); - work.setPreviousState(vm.getState()); - return (System.currentTimeMillis() >> 10) + _restartRetryInterval; + } catch (final InsufficientCapacityException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); - return null; } catch (final ResourceUnavailableException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); - return null; } catch (ConcurrentOperationException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); - return null; } catch (OperationTimedoutException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); - return null; } + vm = _itMgr.findById(vm.getType(), vm.getId()); + work.setUpdateTime(vm.getUpdated()); + work.setPreviousState(vm.getState()); + return (System.currentTimeMillis() >> 10) + _restartRetryInterval; } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 86f1fe4714a..99614daaff8 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -614,24 +614,25 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene avoids.addHost(destHostId); continue; } catch (ResourceUnavailableException e) { + s_logger.info("Unable to contact resource.", e); if (!avoids.add(e)) { if (e.getScope() == Volume.class || e.getScope() == Nic.class) { throw e; } else { - throw new CloudRuntimeException("Resource is not available to start the VM.", e); + s_logger.warn("unexpected ResourceUnavailableException : " + e.getScope().getName(), e); + throw e; } } - s_logger.info("Unable to contact resource.", e); continue; } catch (InsufficientCapacityException e) { + s_logger.info("Insufficient capacity ", e); if (!avoids.add(e)) { if (e.getScope() == Volume.class || e.getScope() == Nic.class) { throw e; } else { - throw new CloudRuntimeException("Insufficient capacity to start the VM.", e); + s_logger.warn("unexpected InsufficientCapacityException : " + e.getScope().getName(), e); } } - s_logger.info("Insufficient capacity ", e); continue; } catch (RuntimeException e) { s_logger.warn("Failed to start instance " + vm, e); @@ -646,7 +647,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene } finally { if (startedVm == null) { changeState(vm, Event.OperationFailed, null, work, Step.Done); - throw new CloudRuntimeException("Unable to start " + vm); } }