Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDSTACK-9114: Reduce VR downtime during network restart #2508

Merged
merged 7 commits into from May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/src/com/cloud/network/Network.java
Expand Up @@ -351,6 +351,8 @@ public void setIp6Address(String ip6Address) {

boolean isRedundant();

boolean isRollingRestart();

long getRelated();

URI getBroadcastUri();
Expand Down
5 changes: 5 additions & 0 deletions api/src/com/cloud/network/NetworkProfile.java
Expand Up @@ -155,6 +155,11 @@ public boolean isRedundant() {
return this.isRedundant;
}

@Override
public boolean isRollingRestart() {
return false;
}

@Override
public String getName() {
return name;
Expand Down
2 changes: 1 addition & 1 deletion api/src/com/cloud/network/NetworkService.java
Expand Up @@ -70,7 +70,7 @@ IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long ne

boolean deleteNetwork(long networkId, boolean forced);

boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup, boolean makeRedundant) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;

int getActiveNicsInNetwork(long networkId);

Expand Down
4 changes: 4 additions & 0 deletions api/src/com/cloud/network/vpc/Vpc.java
Expand Up @@ -87,4 +87,8 @@ public enum State {
* @return true if VPC spans multiple zones in the region
*/
boolean isRegionLevelVpc();

boolean isRollingRestart();

void setRollingRestart(boolean rollingRestart);
}
3 changes: 2 additions & 1 deletion api/src/org/apache/cloudstack/api/ApiConstants.java
Expand Up @@ -56,7 +56,7 @@ public class ApiConstants {
public static final String CIDR_LIST = "cidrlist";
public static final String DEST_CIDR_LIST = "destcidrlist";
public static final String CLEANUP = "cleanup";
public static final String MAKEREDUNDANTE = "makeredundant";
public static final String MAKEREDUNDANT = "makeredundant";
public static final String CLUSTER_ID = "clusterid";
public static final String CLUSTER_NAME = "clustername";
public static final String CLUSTER_TYPE = "clustertype";
Expand Down Expand Up @@ -681,6 +681,7 @@ public class ApiConstants {
public static final String REMAININGCAPACITY = "remainingcapacity";
public static final String MAXCAPACITY = "maxcapacity";
public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter";
public static final String REDUNDANT_ROUTER = "redundantrouter";
public static final String REDUNDANT_VPC_ROUTER = "redundantvpcrouter";
public static final String READ_ONLY = "readonly";
public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
Expand Down
Expand Up @@ -55,7 +55,10 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
private Long id;

@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN, required = false, description = "If cleanup old network elements")
private Boolean cleanup;
private Boolean cleanup = false;

@Parameter(name = ApiConstants.MAKEREDUNDANT, type = CommandType.BOOLEAN, required = false, description = "Turn the network into a network with redundant routers.", since = "4.11.1")
private Boolean makeRedundant = false;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
Expand All @@ -71,10 +74,11 @@ public Long getNetworkId() {
}

public Boolean getCleanup() {
if (cleanup != null) {
return cleanup;
}
return true;
return cleanup;
}

public Boolean getMakeRedundant() {
return makeRedundant;
}

/////////////////////////////////////////////////////
Expand All @@ -92,7 +96,7 @@ public static String getResultObjectName() {

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
boolean result = _networkService.restartNetwork(this, getCleanup());
boolean result = _networkService.restartNetwork(this, getCleanup(), getMakeRedundant());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
Expand Down
Expand Up @@ -49,10 +49,10 @@ public class RestartVPCCmd extends BaseAsyncCmd {
private Long id;

@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN, required = false, description = "If cleanup old network elements")
private Boolean cleanup;
private Boolean cleanup = false;

@Parameter(name = ApiConstants.MAKEREDUNDANTE, type = CommandType.BOOLEAN, required = false, description = "Turn a single VPC into a redundant one.")
private Boolean makeredundant;
@Parameter(name = ApiConstants.MAKEREDUNDANT, type = CommandType.BOOLEAN, required = false, description = "Turn a single VPC into a redundant one.")
private Boolean makeredundant = false;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
Expand All @@ -63,17 +63,11 @@ public Long getId() {
}

public Boolean getCleanup() {
if (cleanup != null) {
return cleanup;
}
return true;
return cleanup;
}

public Boolean getMakeredundant() {
if (makeredundant != null) {
return makeredundant;
}
return true;
return makeredundant;
}

/////////////////////////////////////////////////////
Expand Down
12 changes: 12 additions & 0 deletions api/src/org/apache/cloudstack/api/response/NetworkResponse.java
Expand Up @@ -229,6 +229,10 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@Param(description = "The external id of the network", since = "4.11")
private String externalId;

@SerializedName(ApiConstants.REDUNDANT_ROUTER)
@Param(description = "If the network has redundant routers enabled", since = "4.11.1")
private Boolean redundantRouter;

public Boolean getDisplayNetwork() {
return displayNetwork;
}
Expand Down Expand Up @@ -437,4 +441,12 @@ public void setNetworkSpannedZones(Set<String> networkSpannedZones) {
public void setExternalId(String externalId) {
this.externalId = externalId;
}

public Boolean getRedundantRouter() {
return redundantRouter;
}

public void setRedundantRouter(Boolean redundantRouter) {
this.redundantRouter = redundantRouter;
}
}
Expand Up @@ -43,6 +43,7 @@
import com.cloud.network.element.StaticNatServiceProvider;
import com.cloud.network.element.UserDataServiceProvider;
import com.cloud.network.guru.NetworkGuru;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
Expand All @@ -65,6 +66,12 @@ public interface NetworkOrchestrationService {
String NetworkThrottlingRateCK = "network.throttling.rate";
String MinVRVersionCK = "minreq.sysvmtemplate.version";

/**
* The redundant router handover time which is defined by VRRP2 spec as:
* (3 * advertisement interval + skew_seconds) or 10s with CloudStack default
*/
Long RVRHandoverTime = 10000L;

ConfigKey<String> MinVRVersion = new ConfigKey<String>(String.class, MinVRVersionCK, "Advanced", "4.10.0",
"What version should the Virtual Routers report", true, ConfigKey.Scope.Zone, null);

Expand Down Expand Up @@ -282,4 +289,21 @@ void implementNetworkElementsAndResources(DeployDestination dest, ReservationCon
void finalizeUpdateInSequence(Network network, boolean success);

List<NetworkGuru> getNetworkGurus();

/**
* destroyExpendableRouters will find and destroy safely destroyable routers
* that are in bad states or are backup routers
* @param routers list of routers
* @param context reservation context
* @throws ResourceUnavailableException
*/
void destroyExpendableRouters(final List<? extends VirtualRouter> routers, final ReservationContext context) throws ResourceUnavailableException;

/**
* areRoutersRunning check if the given list of routers are running
* @param routers list of routers
* @return returns true is all routers are running
*/
boolean areRoutersRunning(final List<? extends VirtualRouter> routers);

}