Skip to content

Commit 6cbc4d7

Browse files
committed
Address review feedback for VPC public network rate
- Remove publicnetworkrate from updateVPCOffering; it is set only at create time - createVPCOffering accepts -1 or 0 (unlimited, stored as -1) or a positive value; values below -1 are rejected - Make vpc_offerings.public_nw_rate a signed int; NULL means the VPC uses the zone setting vpc.public.network.throttling.rate - Omit publicnetworkrate in the VPC offering response when not set - Default vpc.public.network.throttling.rate to -1 and reject values below -1 - Use since 24.0 and consistent API descriptions - migrateVPC: copy VPC details after the tiers are migrated and skip publicnetworkrate, which left a stale rate on the migrated VPC - UI: allow -1 on the Add VPC offering form, drop the edit field - Add unit tests
1 parent 007bf8b commit 6cbc4d7

23 files changed

Lines changed: 239 additions & 63 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
166166
private Boolean conserveMode;
167167

168168
@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")
169+
since = "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. Use -1 (or 0) for unlimited. If not specified, VPCs created with this offering use the zone level setting vpc.public.network.throttling.rate")
171171
private Integer publicNetworkRate;
172172

173173

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ 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-
7671
/////////////////////////////////////////////////////
7772
/////////////////// Accessors ///////////////////////
7873
/////////////////////////////////////////////////////
@@ -105,10 +100,6 @@ public Integer getSortKey() {
105100
return sortKey;
106101
}
107102

108-
public Integer getPublicNetworkRate() {
109-
return publicNetworkRate;
110-
}
111-
112103
/////////////////////////////////////////////////////
113104
/////////////// API Implementation///////////////////
114105
/////////////////////////////////////////////////////

‎api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
312312
private Integer privateMtu;
313313

314314
@SerializedName(ApiConstants.NETWORKRATE)
315-
@Param(description = "Network rate (in Mb/s) configured for the Guest interface of this network; -1 if unlimited", since = "4.24.0")
315+
@Param(description = "Network rate (in Mb/s) configured for the Guest interface of this network; -1 if unlimited", since = "24.0")
316316
private Integer networkRate;
317317

318318
@SerializedName(ApiConstants.IP6_DNS1)

‎api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public class NicResponse extends BaseResponse {
139139
private Integer mtu;
140140

141141
@SerializedName(ApiConstants.NETWORKRATE)
142-
@Param(description = "Network rate (in Mb/s) configured for the NIC; -1 if unlimited", since = "4.24.0")
142+
@Param(description = "Network rate (in Mb/s) configured for the NIC; -1 if unlimited", since = "24.0")
143143
private Integer networkRate;
144144

145145
@SerializedName(ApiConstants.PUBLIC_IP_ID)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class VpcOfferingResponse extends BaseResponse {
107107
private Boolean conserveMode;
108108

109109
@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; -1 if unset (falls back to the zone/global default) or unlimited", since = "4.24.0")
110+
@Param(description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering; -1 if unlimited. Not returned if no rate is set on the offering, in which case VPCs created with it use the zone level setting vpc.public.network.throttling.rate", since = "24.0")
111111
private Integer publicNetworkRate;
112112

113113
public void setId(String id) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
7878
private Boolean vpcOfferingConserveMode;
7979

8080
@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")
81+
@Param(description = "Data transfer rate in megabits per second allowed for this VPC's public gateway (internet-facing network); -1 if unlimited", since = "24.0")
8282
private Integer publicNetworkRate;
8383

8484
@SerializedName(ApiConstants.CREATED)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ 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);
141+
ConfigKey<Integer> VpcPublicNetworkThrottlingRate = new ConfigKey<>("Network", Integer.class, "vpc.public.network.throttling.rate", "-1",
142+
"Default data transfer rate in megabits per second allowed for a VPC's public/internet-facing network, used when the VPC offering does not specify a rate. -1 or 0 means unlimited.", true, ConfigKey.Scope.Zone);
143143

144144
List<? extends Network> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
145145
throws ConcurrentOperationException;

‎engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
ALTER TABLE `cloud`.`nics` ADD COLUMN `network_rate` int DEFAULT NULL COMMENT 'effective network rate in Mb/s for this NIC, -1 means unlimited';
2323

24-
ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN `public_nw_rate` int unsigned DEFAULT NULL COMMENT 'public gateway (internet-facing) network rate throttle mbits/s';
24+
ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN `public_nw_rate` int DEFAULT NULL COMMENT 'public gateway (internet-facing) network rate throttle mbits/s';

‎server/src/main/java/com/cloud/api/query/dao/VpcOfferingJoinDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public VpcOfferingResponse newVpcOfferingResponse(VpcOffering offering) {
7979
}
8080
offeringResponse.setConserveMode(offering.isConserveMode());
8181
Integer pubNetworkRate = offering.getPublicNetworkRate();
82-
offeringResponse.setPublicNetworkRate((pubNetworkRate == null || pubNetworkRate <= 0 ) ? -1 : pubNetworkRate);
82+
offeringResponse.setPublicNetworkRate(pubNetworkRate);
8383
if (offering instanceof VpcOfferingJoinVO) {
8484
VpcOfferingJoinVO offeringJoinVO = (VpcOfferingJoinVO) offering;
8585
offeringResponse.setDomainId(offeringJoinVO.getDomainUuid());

‎server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,11 @@ protected String validateValueRange(String name, String value, Class<?> type, Co
15291529
return String.format("[%s] value should be between 0 and 255. 0 value will disable this feature.", name);
15301530
}
15311531
}
1532+
if (NetworkOrchestrationService.VpcPublicNetworkThrottlingRate.key().equalsIgnoreCase(name)) {
1533+
if (val < -1) {
1534+
return String.format("Please enter -1 or 0 (unlimited) or a positive value for the configuration parameter: [%s].", name);
1535+
}
1536+
}
15321537
if (UnmanagedVMsManager.ThreadsOnMSToImportVMwareVMFiles.key().equalsIgnoreCase(name) ||
15331538
UnmanagedVMsManager.ThreadsOnKVMHostToImportVMwareVMFiles.key().equalsIgnoreCase(name)) {
15341539
if (val < -1 || val > 10) {
@@ -9080,9 +9085,7 @@ public Integer getVpcOfferingNetworkRate(final long vpcOfferingId, final Long da
90809085
networkRate = NetworkOrchestrationService.VpcPublicNetworkThrottlingRate.valueIn(dataCenterId);
90819086
}
90829087

9083-
// networkRate is unsigned int in vpc_offerings table, and can't be
9084-
// set to -1
9085-
// so 0 means unlimited; we convert it to -1, so we are consistent with
9088+
// 0 also means unlimited; we convert it to -1, so we are consistent with
90869089
// all our other resources where -1 means unlimited
90879090
if (networkRate == 0) {
90889091
networkRate = -1;

0 commit comments

Comments
 (0)