Skip to content

Commit 4aa73f3

Browse files
committed
CLOUDSTACK-9074: Error handling when conflicts in NSX side
1 parent 5d03cd2 commit 4aa73f3

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4575,7 +4575,13 @@ private Pair<JobInfo.Status, String> orchestrateStart(final VmWorkStart work) th
45754575
}
45764576
assert vm != null;
45774577

4578-
orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner()));
4578+
try{
4579+
orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner()));
4580+
}
4581+
catch (CloudRuntimeException e){
4582+
s_logger.info("[NSX_PLUGIN_LOG] Caught CloudRuntimeException, returning job failed");
4583+
return new Pair<JobInfo.Status, String>(JobInfo.Status.FAILED, null);
4584+
}
45794585
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null);
45804586
}
45814587

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,14 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDesti
10331033
} catch (NoTransitionException e) {
10341034
s_logger.error(e.getMessage());
10351035
return null;
1036+
} catch (CloudRuntimeException e) {
1037+
s_logger.error("[NSX_PLUGIN_LOG] NetworkOrchestor caught exception " + e.getMessage() + " returning null");
1038+
return null;
10361039
} finally {
10371040
if (implemented.first() == null) {
10381041
s_logger.debug("Cleaning up because we're unable to implement the network " + network);
10391042
try {
1043+
s_logger.info("[NSX_PLUGIN_LOG] isSharedNetworkWithServices? " + isSharedNetworkWithServices(network));
10401044
if (isSharedNetworkWithServices(network)) {
10411045
network.setState(Network.State.Shutdown);
10421046
_networksDao.update(networkId, network);

plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/resource/wrapper/NiciraNvpConfigureSharedNetworkUuidCommandWrapper.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public Answer execute(ConfigureSharedNetworkUuidCommand command, NiciraNvpResour
7070
ipAddresses.add(portIpAddress);
7171
lrpi.setIpAddresses(ipAddresses);
7272
lrpi = niciraNvpApi.createLogicalRouterPort(logicalRouterUuid, lrpi);
73-
7473
try {
7574
// Create the inside port on the lswitch
7675
lsp = new LogicalSwitchPort(niciraNvpResource.truncate(networkId + "-shared-att-port", NAME_MAX_LEN), tags, true);
@@ -89,22 +88,16 @@ public Answer execute(ConfigureSharedNetworkUuidCommand command, NiciraNvpResour
8988
niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
9089
}
9190
} catch (NiciraNvpApiException ex) {
91+
throw new NiciraNvpApiException(e.getMessage() + " and " + ex.getMessage());
9292
}
9393
throw e;
9494
}
9595

96+
return new ConfigureSharedNetworkUuidAnswer(command, true, "OK");
9697
}
9798
catch (final NiciraNvpApiException e) {
98-
try {
99-
String msg = "Attempt to add overlapping networks to the routing domain. Router ID " +
100-
logicalRouterUuid + ". Network gateway " + portIpAddress +
101-
" (" + e.getMessage() + ")";
102-
throw new NiciraNvpApiException(msg);
103-
} catch (NiciraNvpApiException e1) {
104-
}
99+
return new ConfigureSharedNetworkUuidAnswer(command, false, e.getMessage());
105100
}
106-
107-
return new ConfigureSharedNetworkUuidAnswer(command, true, "OK");
108101
}
109102

110103
}

plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/resource/wrapper/NiciraNvpConfigureSharedNetworkVlanIdCommandWrapper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,20 @@ public Answer execute(ConfigureSharedNetworkVlanIdCommand command, NiciraNvpReso
7474
}
7575
catch (NiciraNvpApiException e){
7676
try {
77+
s_logger.info("Error while updating lswitch port: " + e.getMessage() + " , deleting lswitch port" );
7778
niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
7879
} catch (NiciraNvpApiException e1) {
80+
throw new NiciraNvpApiException(e.getMessage() + " and " + e1.getMessage());
7981
}
8082
throw e;
8183
}
84+
85+
return new ConfigureSharedNetworkVlanIdAnswer(command, true, "OK");
8286
}
8387
catch (NiciraNvpApiException e){
84-
try {
85-
throw e;
86-
} catch (NiciraNvpApiException e1) {
87-
}
88+
return new ConfigureSharedNetworkVlanIdAnswer(command, false, e.getMessage());
8889
}
8990

90-
return new ConfigureSharedNetworkVlanIdAnswer(command, true, "OK");
9191
}
9292

9393
}

0 commit comments

Comments
 (0)