TK-3135 fixes for VPC restart

* removed the "is redundant" flag form the addVpcRouterToGuestNetwork() method
* removed the "is redundant" flag from the removeVpcRouterFromGuestNetwork() method
* changed the path of the master.py file in the keepalived.conf.temp file
* the call to routerDao.addRouterToGuestNetwork() in the VpcRouterDeploymentDefinition is not needed. That step will be performed once a VM is created
  - In addition, when restarting a VPC the routers will have the guest net configured, if any exists.

* Pushing the POM.xml as well, to use the old Jetty for now. Could not fix the logging problem. Will replace the POM with master version after VPC is done.
This commit is contained in:
wilderrodrigues 2015-01-07 08:59:39 +01:00
parent 35151961be
commit 40eb579115
14 changed files with 331 additions and 335 deletions

View File

@ -36,7 +36,7 @@ public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplian
* @throws ResourceUnavailableException
* @throws InsufficientCapacityException
*/
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant, Map<VirtualMachineProfile.Param, Object> params)
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, Map<VirtualMachineProfile.Param, Object> params)
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
/**
@ -47,6 +47,6 @@ public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplian
* @throws ConcurrentOperationException
* @throws ResourceUnavailableException
*/
boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException;
boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
}

View File

@ -419,23 +419,23 @@
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.6.v20141205</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${cs.mysql.version}</version>
</dependency>
</dependencies>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${cs.mysql.version}</version>
</dependency>
</dependencies>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<stopPort>9966</stopPort>
<stopKey>stop-jetty</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
@ -446,6 +446,13 @@
<contextPath>/client</contextPath>
<extraClasspath>${project.build.directory}/utilities/scripts/db/;${project.build.directory}/utilities/scripts/db/db/</extraClasspath>
</webAppConfig>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>log4j-cloud.xml</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<plugin>

View File

@ -943,7 +943,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (planChangedByVolume) {
plan = originalPlan;
planChangedByVolume = false;
//do not enter volume reuse for next retry, since we want to look for resorces outside the volume's cluster
//do not enter volume reuse for next retry, since we want to look for resources outside the volume's cluster
reuseVolume = false;
continue;
}

View File

@ -188,11 +188,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
}
// [FIXME] Comment added by Wilder Rodrigues - This exception has to be removed once we are able to test multiple routers.
// if (routers.size() > 1) {
// throw new CloudRuntimeException("Found more than one router in vpc " + vpc);
// }
s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!");
for (final DomainRouterVO domainRouterVO : routers) {
@ -201,7 +196,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
if (network.getState() == State.Setup) {
paramsForRouter.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
}
if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(domainRouterVO, network, false, paramsForRouter)) {
if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(domainRouterVO, network, paramsForRouter)) {
s_logger.error("Failed to add VPC router " + domainRouterVO + " to guest network " + network);
} else {
s_logger.debug("Successfully added VPC router " + domainRouterVO + " to guest network " + network);
@ -240,11 +235,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
}
// [FIXME] Comment added by Wilder Rodrigues - This exception has to be removed once we are able to test multiple routers.
// if (routers.size() > 1) {
// throw new CloudRuntimeException("Found more than one router in vpc " + vpc);
// }
s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!");
for (final DomainRouterVO domainRouterVO : routers) {
@ -255,7 +245,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
if (network.getState() == State.Setup) {
paramsForRouter.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
}
if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(domainRouterVO, network, false, paramsForRouter)) {
if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(domainRouterVO, network, paramsForRouter)) {
s_logger.error("Failed to add VPC router " + domainRouterVO + " to guest network " + network);
} else {
s_logger.debug("Successfully added VPC router " + domainRouterVO + " to guest network " + network);
@ -284,7 +274,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
continue;
}
// 2) Call unplugNics in the network service
success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, network, false);
success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, network);
if (!success) {
s_logger.warn("Failed to unplug nic in network " + network + " for virtual router " + router);
} else {
@ -312,7 +302,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
continue;
}
// 2) Call unplugNics in the network service
success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config, false);
success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config);
if (!success) {
s_logger.warn("Failed to unplug nic in network " + config + " for virtual router " + router);
} else {
@ -372,11 +362,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
return true;
}
// [FIXME] Comment added by Wilder Rodrigues - This exception has to be removed once we are able to test multiple routers.
// if (routers.size() > 1) {
// throw new CloudRuntimeException("Found more than one router in vpc " + vpc);
// }
s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!");
final DataCenterVO dcVO = _dcDao.findById(gateway.getZoneId());
@ -416,11 +401,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
return true;
}
// [FIXME] Comment added by Wilder Rodrigues - This exception has to be removed once we are able to test multiple routers.
// if (routers.size() > 1) {
// throw new CloudRuntimeException("Found more than one router in vpc " + vpc);
// }
s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!");
int result = 0;

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.network.router;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -30,9 +31,11 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.network.Network;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachineProfile.Param;
public interface NetworkHelper {
@ -73,9 +76,11 @@ public interface NetworkHelper {
ConcurrentOperationException, ResourceUnavailableException;
public abstract DomainRouterVO deployRouter(
RouterDeploymentDefinition routerDeploymentDefinition,
boolean startRouter)
RouterDeploymentDefinition routerDeploymentDefinition, boolean startRouter)
throws InsufficientAddressCapacityException,
InsufficientServerCapacityException, InsufficientCapacityException,
StorageUnavailableException, ResourceUnavailableException;
public abstract LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(RouterDeploymentDefinition routerDeploymentDefinition)
throws ConcurrentOperationException, InsufficientAddressCapacityException;
}

View File

@ -474,8 +474,8 @@ public class NetworkHelperImpl implements NetworkHelper {
}
@Override
public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition, final boolean startRouter) throws InsufficientAddressCapacityException,
InsufficientServerCapacityException, InsufficientCapacityException, StorageUnavailableException, ResourceUnavailableException {
public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition, final boolean startRouter)
throws InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException, StorageUnavailableException, ResourceUnavailableException {
final ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(routerDeploymentDefinition.getServiceOfferingId());
final Account owner = routerDeploymentDefinition.getOwner();
@ -530,7 +530,9 @@ public class NetworkHelperImpl implements NetworkHelper {
router.setDynamicallyScalable(template.isDynamicallyScalable());
router.setRole(Role.VIRTUAL_ROUTER);
router = _routerDao.persist(router);
final LinkedHashMap<Network, List<? extends NicProfile>> networks = createRouterNetworks(routerDeploymentDefinition);
_itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, routerDeploymentDefinition.getPlan(), null);
router = _routerDao.findById(router.getId());
} catch (final InsufficientCapacityException ex) {
@ -642,6 +644,7 @@ public class NetworkHelperImpl implements NetworkHelper {
throw new CloudRuntimeException(errMsg);
}
@Override
public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(final RouterDeploymentDefinition routerDeploymentDefinition)
throws ConcurrentOperationException, InsufficientAddressCapacityException {

View File

@ -127,7 +127,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
}
@Override
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant, final Map<VirtualMachineProfile.Param, Object> params)
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final Map<VirtualMachineProfile.Param, Object> params)
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
if (network.getTrafficType() != TrafficType.Guest) {
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
@ -159,7 +159,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
} finally {
if (!result) {
s_logger.debug("Removing the router " + router + " from network " + network + " as a part of cleanup");
if (removeVpcRouterFromGuestNetwork(router, network, isRedundant)) {
if (removeVpcRouterFromGuestNetwork(router, network)) {
s_logger.debug("Removed the router " + router + " from network " + network + " as a part of cleanup");
} else {
s_logger.warn("Failed to remove the router " + router + " from network " + network + " as a part of cleanup");
@ -173,7 +173,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
}
@Override
public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant) throws ConcurrentOperationException,
public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network) throws ConcurrentOperationException,
ResourceUnavailableException {
if (network.getTrafficType() != TrafficType.Guest) {
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);

View File

@ -16,6 +16,16 @@
// under the License.
package org.cloud.network.router.deployment;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DeployDestination;
@ -42,14 +52,6 @@ import com.cloud.vm.VirtualMachineProfile.Param;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.VMInstanceDao;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class RouterDeploymentDefinitionBuilder {
@ -170,7 +172,7 @@ public class RouterDeploymentDefinitionBuilder {
}
public IntermediateStateBuilder setGuestNetwork(final Network nw) {
this.guestNetwork = nw;
guestNetwork = nw;
return this;
}

View File

@ -186,7 +186,6 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
final DomainRouterVO router = nwHelper.deployRouter(this, false);
if (router != null) {
// TODO this.routerDao.addRouterToGuestNetwork(router, this.guestNetwork);
routers.add(router);
}
}

View File

@ -191,7 +191,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
* @see com.cloud.network.VpcVirtualNetworkApplianceService#addVpcRouterToGuestNetwork(com.cloud.network.router.VirtualRouter, com.cloud.network.Network, boolean)
*/
@Override
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant, final Map<VirtualMachineProfile.Param, Object> params)
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final Map<VirtualMachineProfile.Param, Object> params)
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// TODO Auto-generated method stub
return false;
@ -201,7 +201,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
* @see com.cloud.network.VpcVirtualNetworkApplianceService#removeVpcRouterFromGuestNetwork(com.cloud.network.router.VirtualRouter, com.cloud.network.Network, boolean)
*/
@Override
public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant) throws ConcurrentOperationException {
public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network) throws ConcurrentOperationException {
// TODO Auto-generated method stub
return false;
}

View File

@ -123,12 +123,12 @@ public class RouterDeploymentDefinitionTestBase {
protected void initMocks() {
when(this.mockDestination.getDataCenter()).thenReturn(this.mockDataCenter);
when(this.mockDataCenter.getId()).thenReturn(DATA_CENTER_ID);
when(this.mockPod.getId()).thenReturn(POD_ID1);
when(this.mockHostPodVO1.getId()).thenReturn(POD_ID1);
when(this.mockHostPodVO2.getId()).thenReturn(POD_ID2);
when(this.mockHostPodVO3.getId()).thenReturn(POD_ID3);
when(this.mockNw.getId()).thenReturn(NW_ID_1);
when(mockDestination.getDataCenter()).thenReturn(mockDataCenter);
when(mockDataCenter.getId()).thenReturn(DATA_CENTER_ID);
when(mockPod.getId()).thenReturn(POD_ID1);
when(mockHostPodVO1.getId()).thenReturn(POD_ID1);
when(mockHostPodVO2.getId()).thenReturn(POD_ID2);
when(mockHostPodVO3.getId()).thenReturn(POD_ID3);
when(mockNw.getId()).thenReturn(NW_ID_1);
}
}

View File

@ -17,17 +17,16 @@
package org.cloud.network.router.deployment;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertFalse;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.cloud.network.vpc.VpcOfferingVO;
import java.util.List;
import org.junit.Before;
@ -46,6 +45,7 @@ import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.router.NicProfileHelper;
import com.cloud.network.vpc.VpcManager;
import com.cloud.network.vpc.VpcOfferingVO;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.network.vpc.dao.VpcOfferingDao;
@ -154,7 +154,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testFindDestinations() {
// Execute
List<DeployDestination> foundDestinations = deployment.findDestinations();
final List<DeployDestination> foundDestinations = deployment.findDestinations();
// Assert
assertEquals(FOR_VPC_ONLY_THE_GIVEN_DESTINATION_SHOULD_BE_USED, deployment.dest, foundDestinations.get(0));
assertEquals(FOR_VPC_ONLY_THE_GIVEN_DESTINATION_SHOULD_BE_USED, 1, foundDestinations.size());
@ -180,8 +180,8 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testFindOfferingIdLeavingPrevious() {
// Prepare
Long initialOfferingId = deployment.serviceOfferingId;
VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
final Long initialOfferingId = deployment.serviceOfferingId;
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
when(vpcOffering.getServiceOfferingId()).thenReturn(null);
@ -196,7 +196,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testFindOfferingIdSettingNewOne() {
// Prepare
VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
when(vpcOffering.getServiceOfferingId()).thenReturn(VPC_OFFERING_ID);
@ -215,7 +215,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testDeployAllVirtualRoutersWithNoDeployedRouter() throws InsufficientAddressCapacityException, InsufficientServerCapacityException, StorageUnavailableException,
InsufficientCapacityException, ResourceUnavailableException {
InsufficientCapacityException, ResourceUnavailableException {
driveTestDeployAllVirtualRouters(null);
@ -225,9 +225,9 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
}
public void driveTestDeployAllVirtualRouters(final DomainRouterVO router) throws InsufficientAddressCapacityException, InsufficientServerCapacityException,
StorageUnavailableException, InsufficientCapacityException, ResourceUnavailableException {
StorageUnavailableException, InsufficientCapacityException, ResourceUnavailableException {
// Prepare
VpcRouterDeploymentDefinition vpcDeployment = (VpcRouterDeploymentDefinition) deployment;
final VpcRouterDeploymentDefinition vpcDeployment = (VpcRouterDeploymentDefinition) deployment;
when(vpcDeployment.nwHelper.deployRouter(vpcDeployment, true)).thenReturn(router);
// Execute
@ -242,7 +242,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testFindSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException {
// Prepare
PublicIp publicIp = mock(PublicIp.class);
final PublicIp publicIp = mock(PublicIp.class);
when(vpcMgr.assignSourceNatIpAddressToVpc(mockOwner, mockVpc)).thenReturn(publicIp);
// Execute
@ -255,13 +255,13 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
@Test
public void testRedundancyProperty() {
// Set and confirm is redundant
when(this.mockVpc.isRedundant()).thenReturn(true);
RouterDeploymentDefinition deployment = this.builder.create()
.setVpc(this.mockVpc)
.setDeployDestination(this.mockDestination)
when(mockVpc.isRedundant()).thenReturn(true);
final RouterDeploymentDefinition deployment = builder.create()
.setVpc(mockVpc)
.setDeployDestination(mockDestination)
.build();
assertTrue("The builder ignored redundancy from its inner network", deployment.isRedundant());
when(this.mockVpc.isRedundant()).thenReturn(false);
when(mockVpc.isRedundant()).thenReturn(false);
assertFalse("The builder ignored redundancy from its inner network", deployment.isRedundant());
}
}

View File

@ -52,7 +52,7 @@ vrrp_instance inside_network {
}
!That's the correct path of the master.py file.
notify_master "/cloud_scripts/opt/cloud/bin/master.py --master"
notify_backup "/cloud_scripts/opt/cloud/bin/master.py --backup"
notify_fault "/cloud_scripts/opt/cloud/bin/master.py --fault"
notify_master "/root/cloud_scripts/opt/cloud/bin/master.py --master"
notify_backup "/root/cloud_scripts/opt/cloud/bin/master.py --backup"
notify_fault "/root/cloud_scripts/opt/cloud/bin/master.py --fault"
}