You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2014/11/19 05:24:01 UTC
git commit: updated refs/heads/master to 4e89693
Repository: cloudstack
Updated Branches:
refs/heads/master 20a8852db -> 4e896938e
BUG-ID: CLOUDSTACK-5324 when router requires upgrade throw ResourceUnavailableException with scope VirtualRouter. API willl return generic Network Unavailable error.
Reviewed-By: Damoder
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4e896938
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4e896938
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4e896938
Branch: refs/heads/master
Commit: 4e896938ee6aac3945c9bf0d9e67423482e87be4
Parents: 20a8852
Author: Kishan Kavala <ki...@apache.org>
Authored: Wed Nov 19 09:46:34 2014 +0530
Committer: Kishan Kavala <ki...@apache.org>
Committed: Wed Nov 19 09:46:56 2014 +0530
----------------------------------------------------------------------
.../src/com/cloud/vm/VirtualMachineManagerImpl.java | 7 ++++++-
server/src/com/cloud/network/router/NetworkHelper.java | 2 +-
.../src/com/cloud/network/router/NetworkHelperImpl.java | 4 ++--
.../network/router/VirtualNetworkApplianceManager.java | 4 ++--
.../router/VirtualNetworkApplianceManagerImpl.java | 6 +++---
.../com/cloud/network/router/NetworkHelperImplTest.java | 12 ++++++------
6 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 5096ed4..c9322e4 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -38,6 +38,7 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import com.cloud.network.router.VirtualRouter;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
@@ -609,8 +610,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (InsufficientCapacityException e) {
throw new CloudRuntimeException("Unable to start a VM due to insufficient capacity", e).add(VirtualMachine.class, vmUuid);
} catch (ResourceUnavailableException e) {
- throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
+ if(e.getScope() != null && e.getScope().equals(VirtualRouter.class)){
+ throw new CloudRuntimeException("Network is unavailable. Please contact administrator", e).add(VirtualMachine.class, vmUuid);
+ }
+ throw new CloudRuntimeException("Unable to start a VM due to unavailable resources", e).add(VirtualMachine.class, vmUuid);
}
+
}
protected boolean checkWorkItems(VMInstanceVO vm, State state) throws ConcurrentOperationException {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/server/src/com/cloud/network/router/NetworkHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelper.java b/server/src/com/cloud/network/router/NetworkHelper.java
index 711c02d..6c61016 100644
--- a/server/src/com/cloud/network/router/NetworkHelper.java
+++ b/server/src/com/cloud/network/router/NetworkHelper.java
@@ -38,7 +38,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
public interface NetworkHelper {
public abstract boolean sendCommandsToRouter(VirtualRouter router,
- Commands cmds) throws AgentUnavailableException;
+ Commands cmds) throws AgentUnavailableException, ResourceUnavailableException;
public abstract void handleSingleWorkingRedundantRouter(
List<? extends VirtualRouter> connectedRouters,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/server/src/com/cloud/network/router/NetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelperImpl.java b/server/src/com/cloud/network/router/NetworkHelperImpl.java
index d2b160f..968251c 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -160,11 +160,11 @@ public class NetworkHelperImpl implements NetworkHelper {
}
@Override
- public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException {
+ public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException, ResourceUnavailableException {
if (!checkRouterVersion(router)) {
s_logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion()
+ ", minimal required version : " + VirtualNetworkApplianceService.MinVRVersion);
- throw new CloudRuntimeException("Unable to send command. Upgrade in progress. Please contact administrator.");
+ throw new ResourceUnavailableException("Unable to send command. Router requires upgrade", VirtualRouter.class, router.getId());
}
Answer[] answers = null;
try {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
index 8e0aba4a..9fb47fd 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
@@ -91,7 +91,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
boolean removeDhcpSupportForSubnet(Network network, List<DomainRouterVO> routers) throws ResourceUnavailableException;
- public boolean prepareAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException;
+ public boolean prepareAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException, ResourceUnavailableException;
- public boolean completeAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException;
+ public boolean completeAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException, ResourceUnavailableException;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 23ddfb1..e56812e 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2605,7 +2605,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
}
protected boolean aggregationExecution(final AggregationControlCommand.Action action, final Network network, final List<DomainRouterVO> routers)
- throws AgentUnavailableException {
+ throws AgentUnavailableException, ResourceUnavailableException {
for (final DomainRouterVO router : routers) {
final AggregationControlCommand cmd = new AggregationControlCommand(action, router.getInstanceName(), getRouterControlIp(router.getId()), getRouterIpInNetwork(
network.getId(), router.getId()));
@@ -2618,12 +2618,12 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
}
@Override
- public boolean prepareAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
+ public boolean prepareAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException, ResourceUnavailableException {
return aggregationExecution(Action.Start, network, routers);
}
@Override
- public boolean completeAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
+ public boolean completeAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException, ResourceUnavailableException {
return aggregationExecution(Action.Finish, network, routers);
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e896938/server/test/com/cloud/network/router/NetworkHelperImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/router/NetworkHelperImplTest.java b/server/test/com/cloud/network/router/NetworkHelperImplTest.java
index 74a0a60..952818d 100644
--- a/server/test/com/cloud/network/router/NetworkHelperImplTest.java
+++ b/server/test/com/cloud/network/router/NetworkHelperImplTest.java
@@ -38,7 +38,7 @@ import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.OperationTimedoutException;
-import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.exception.ResourceUnavailableException;
@RunWith(MockitoJUnitRunner.class)
@@ -52,9 +52,9 @@ public class NetworkHelperImplTest {
@InjectMocks
protected NetworkHelperImpl nwHelper = new NetworkHelperImpl();
- @Test(expected=CloudRuntimeException.class)
+ @Test(expected=ResourceUnavailableException.class)
public void testSendCommandsToRouterWrongRouterVersion()
- throws AgentUnavailableException, OperationTimedoutException {
+ throws AgentUnavailableException, OperationTimedoutException, ResourceUnavailableException {
// Prepare
NetworkHelperImpl nwHelperUT = spy(this.nwHelper);
VirtualRouter vr = mock(VirtualRouter.class);
@@ -69,7 +69,7 @@ public class NetworkHelperImplTest {
@Test
public void testSendCommandsToRouter()
- throws AgentUnavailableException, OperationTimedoutException {
+ throws AgentUnavailableException, OperationTimedoutException, ResourceUnavailableException {
// Prepare
NetworkHelperImpl nwHelperUT = spy(this.nwHelper);
VirtualRouter vr = mock(VirtualRouter.class);
@@ -107,7 +107,7 @@ public class NetworkHelperImplTest {
*/
@Test
public void testSendCommandsToRouterWithTrueResult()
- throws AgentUnavailableException, OperationTimedoutException {
+ throws AgentUnavailableException, OperationTimedoutException, ResourceUnavailableException {
// Prepare
NetworkHelperImpl nwHelperUT = spy(this.nwHelper);
VirtualRouter vr = mock(VirtualRouter.class);
@@ -145,7 +145,7 @@ public class NetworkHelperImplTest {
*/
@Test
public void testSendCommandsToRouterWithNoAnswers()
- throws AgentUnavailableException, OperationTimedoutException {
+ throws AgentUnavailableException, OperationTimedoutException, ResourceUnavailableException {
// Prepare
NetworkHelperImpl nwHelperUT = spy(this.nwHelper);
VirtualRouter vr = mock(VirtualRouter.class);