mirror of https://github.com/apache/cloudstack.git
BUG-ID: CLOUDSTACK-5324 when router requires upgrade throw ResourceUnavailableException with scope VirtualRouter. API willl return generic Network Unavailable error.
Reviewed-By: Damoder
This commit is contained in:
parent
20a8852db1
commit
4e896938ee
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue