Skip to content

Commit 7a4e287

Browse files
committed
Support throttling a VPC's public gateway network rate
Adds an operator-configurable data transfer rate for a VPC's public/internet-facing network, independent of the intra-VPC tier rates that network offerings already control. Precedence: vpc_offerings.public_nw_rate (per-offering override) falls back to the new zone-scoped config vpc.public.network.throttling.rate (default 0/unlimited, preserving today's unthrottled behavior on upgrade). - createVPCOffering/updateVPCOffering/cloneVPCOffering accept publicnetworkrate - listVPCOfferings/listVPCs expose it, normalized to -1 for unlimited - vpc_details "publicnetworkrate" cache is (re)computed only where a VPC's offering can actually change: at creation and in restartVpc's make-redundant path - backfills existing VPCs to -1 on upgrade, since the new column/config can't yet hold a value - UI support for setting/viewing the rate on VPC offerings and VPCs
1 parent 4c8b4ef commit 7a4e287

28 files changed

Lines changed: 289 additions & 23 deletions

File tree

api/src/main/java/com/cloud/network/vpc/VpcOffering.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ public enum State {
8686
Boolean isSpecifyAsNumber();
8787

8888
boolean isConserveMode();
89+
90+
Integer getPublicNetworkRate();
8991
}

api/src/main/java/com/cloud/network/vpc/VpcProvisioningService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ VpcOffering createVpcOffering(String name, String displayText, List<String> supp
4242
Map serviceCapabilitystList, NetUtils.InternetProtocol internetProtocol,
4343
Long serviceOfferingId, String externalProvider, NetworkOffering.NetworkMode networkMode,
4444
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state,
45-
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber, boolean conserveMode);
45+
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber, boolean conserveMode, Integer publicNetworkRate);
4646

4747

4848
Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(ListVPCOfferingsCmd cmd);

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ public class ApiConstants {
729729
public static final String IS_USER_DEFINED = "isuserdefined";
730730
public static final String AVAILABILITY = "availability";
731731
public static final String NETWORKRATE = "networkrate";
732+
public static final String PUBLIC_NETWORK_RATE = "publicnetworkrate";
732733
public static final String HOST_TAGS = "hosttags";
733734
public static final String SSH_KEYPAIR = "keypair";
734735
public static final String SSH_KEYPAIRS = "keypairs";

api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
165165
description = "True if the VPC offering is IP conserve mode enabled, allowing public IPs to be used across multiple VPC tiers. Default value is false")
166166
private Boolean conserveMode;
167167

168+
@Parameter(name = ApiConstants.PUBLIC_NETWORK_RATE, type = CommandType.INTEGER,
169+
since = "4.24.0",
170+
description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering. Default is unlimited")
171+
private Integer publicNetworkRate;
172+
168173

169174
/////////////////////////////////////////////////////
170175
/////////////////// Accessors ///////////////////////
@@ -318,6 +323,10 @@ public boolean isConserveMode() {
318323
return BooleanUtils.toBoolean(conserveMode);
319324
}
320325

326+
public Integer getPublicNetworkRate() {
327+
return publicNetworkRate;
328+
}
329+
321330
@Override
322331
public void create() throws ResourceAllocationException {
323332
VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(this);

api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd implements DomainAndZoneI
6868
@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER, description = "Sort key of the VPC offering, integer")
6969
private Integer sortKey;
7070

71+
@Parameter(name = ApiConstants.PUBLIC_NETWORK_RATE, type = CommandType.INTEGER,
72+
since = "4.24.0",
73+
description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering. Use 0 for unlimited")
74+
private Integer publicNetworkRate;
75+
7176
/////////////////////////////////////////////////////
7277
/////////////////// Accessors ///////////////////////
7378
/////////////////////////////////////////////////////
@@ -100,6 +105,10 @@ public Integer getSortKey() {
100105
return sortKey;
101106
}
102107

108+
public Integer getPublicNetworkRate() {
109+
return publicNetworkRate;
110+
}
111+
103112
/////////////////////////////////////////////////////
104113
/////////////// API Implementation///////////////////
105114
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/VpcOfferingResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public class VpcOfferingResponse extends BaseResponse {
106106
@Param(description = "True if the VPC offering is IP conserve mode enabled, allowing public IP services to be used across multiple VPC tiers.", since = "4.23.0")
107107
private Boolean conserveMode;
108108

109+
@SerializedName(ApiConstants.PUBLIC_NETWORK_RATE)
110+
@Param(description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering; null if not set (falls back to the zone/global default)", since = "4.24.0")
111+
private Integer publicNetworkRate;
112+
109113
public void setId(String id) {
110114
this.id = id;
111115
}
@@ -213,4 +217,8 @@ public Boolean getConserveMode() {
213217
public void setConserveMode(Boolean conserveMode) {
214218
this.conserveMode = conserveMode;
215219
}
220+
221+
public void setPublicNetworkRate(Integer publicNetworkRate) {
222+
this.publicNetworkRate = publicNetworkRate;
223+
}
216224
}

api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
7777
@Param(description = "true if VPC offering is ip conserve mode enabled", since = "4.23")
7878
private Boolean vpcOfferingConserveMode;
7979

80+
@SerializedName(ApiConstants.PUBLIC_NETWORK_RATE)
81+
@Param(description = "Data transfer rate in megabits per second allowed for this VPC's public gateway (internet-facing network); -1 if unlimited", since = "4.24.0")
82+
private Integer publicNetworkRate;
83+
8084
@SerializedName(ApiConstants.CREATED)
8185
@Param(description = "The date this VPC was created")
8286
private Date created;
@@ -209,6 +213,10 @@ public void setVpcOfferingConserveMode(Boolean vpcOfferingConserveMode) {
209213
this.vpcOfferingConserveMode = vpcOfferingConserveMode;
210214
}
211215

216+
public void setPublicNetworkRate(Integer publicNetworkRate) {
217+
this.publicNetworkRate = publicNetworkRate;
218+
}
219+
212220
public void setCreated(final Date created) {
213221
this.created = created;
214222
}

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ public interface NetworkOrchestrationService {
138138
ConfigKey<Integer> VmNetworkThrottlingRate = new ConfigKey<Integer>("Network", Integer.class, "vm.network.throttling.rate", "200",
139139
"Default data transfer rate in megabits per second allowed in User vm's default network.", true, ConfigKey.Scope.Zone);
140140

141+
ConfigKey<Integer> VpcPublicNetworkThrottlingRate = new ConfigKey<>("Network", Integer.class, "vpc.public.network.throttling.rate", "0",
142+
"Default data transfer rate in megabits per second allowed for a VPC's public/internet-facing network. 0 means unlimited.", true, ConfigKey.Scope.Zone);
143+
141144
List<? extends Network> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
142145
throws ConcurrentOperationException;
143146

engine/components-api/src/main/java/com/cloud/configuration/ConfigurationManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public interface ConfigurationManager {
8282

8383
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
8484

85+
Integer getVpcOfferingNetworkRate(long vpcOfferingId, Long dataCenterId);
86+
8587
/**
8688
* Updates a configuration entry with a new value
8789
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5075,7 +5075,7 @@ public String getConfigComponentName() {
50755075
@Override
50765076
public ConfigKey<?>[] getConfigKeys() {
50775077
return new ConfigKey<?>[]{NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, DeniedRoutes,
5078-
GuestDomainSuffix, NetworkThrottlingRate, VmNetworkThrottlingRate, MinVRVersion, DhcpLeaseTimeout,
5078+
GuestDomainSuffix, NetworkThrottlingRate, VmNetworkThrottlingRate, VpcPublicNetworkThrottlingRate, MinVRVersion, DhcpLeaseTimeout,
50795079
PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RollingRestartEnabled,
50805080
TUNGSTEN_ENABLED, NSX_ENABLED, NETRIS_ENABLED, NETWORK_LB_HAPROXY_MAX_CONN,
50815081
NETWORK_LB_HAPROXY_IDLE_TIMEOUT};

0 commit comments

Comments
 (0)