erikbocks commented on code in PR #14378:
URL: https://github.com/apache/cloudstack/pull/14378#discussion_r4739453862
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -2263,6 +2264,37 @@ public void doInTransactionWithoutResult(final
TransactionStatus status) {
});
}
+ private void setGuestNetworkVrNicMultiqueueNumber(Pair<NetworkVO, VpcVO>
networks, NetworkVO implementedNetwork, NicProfile nicProfile) {
+ if (networks == null) {
+ logger.debug("Skipping the assignment of multiqueue for VR because
it is not related with any network.");
+ return;
+ }
+
+ VpcVO vpcVO = networks.second();
+ boolean isVpcVr = vpcVO != null;
+ if (isVpcVr) {
+ logger.trace("The multiqueue number for NICs of VPCs VRs is not
defined at this step, skipping it.");
+ return;
+ }
+
+ if (implementedNetwork.getTrafficType() == TrafficType.Control) {
+ logger.trace("The multiqueue number is not applied for NICs of
control networks, skipping it.");
+ return;
+ }
+
+ Network guestNetwork = networks.first();
+ NetworkOffering networkOffering =
_entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class,
guestNetwork.getNetworkOfferingId());
+ Integer offeringMultiqueueNumber = implementedNetwork.getTrafficType()
== TrafficType.Public ? networkOffering.getPublicMultiqueueNumber() :
networkOffering.getPrivateMultiqueueNumber();
+ Integer multiqueueNumber =
NetworkOrchestrationService.getRouterNicMultiqueueNumber(offeringMultiqueueNumber);
+ if (multiqueueNumber == null) {
+ logger.debug("Multiqueue for NIC [{}] will not be defined because
neither the network offering nor the [{}] configuration define it.",
+ nicProfile.getUuid(), RouterNicMultiqueueNumber.key());
+ } else {
+ logger.debug("Setting [{}] as the multiqueue for NIC [{}].",
multiqueueNumber, nicProfile.getUuid());
+ nicProfile.setMultiqueueNumber(multiqueueNumber);
+ }
Review Comment:
```suggestion
Integer multiqueueNumber =
NetworkOrchestrationService.getRouterNicMultiqueueNumber(offeringMultiqueueNumber);
if (multiqueueNumber == null) {
logger.debug("Multiqueue for NIC [{}] will not be defined
because neither the network offering nor the [{}] configuration define it.",
nicProfile.getUuid(), RouterNicMultiqueueNumber.key());
return;
}
logger.debug("Setting [{}] as the multiqueue for NIC [{}].",
multiqueueNumber, nicProfile.getUuid());
nicProfile.setMultiqueueNumber(multiqueueNumber);
}
```
Just a minor nit here, but I like to avoid else blocks. This suggestion is
totally optional and can be ignored
##########
ui/src/views/offering/AddNetworkOffering.vue:
##########
@@ -1286,6 +1319,16 @@ export default {
return Promise.reject(this.$t('message.error.number'))
}
return Promise.resolve()
+ },
+ validateMultiqueueValue (rule, value) {
+ if (!value) {
+ return Promise.resolve()
+ }
+ const multiqueue = Number(value)
+ if (Number.isNaN(multiqueue) || (multiqueue <= 0 && multiqueue !== -1)
|| multiqueue > 256) {
+ return Promise.reject(this.$t('message.error.number'))
Review Comment:
Wouldn't it be good to show a more descriptive error message about the
limits of multi queue numbers?
##########
server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java:
##########
@@ -642,17 +645,42 @@ public VpcOffering createVpcOffering(CreateVPCOfferingCmd
cmd) {
throw new InvalidParameterValueException(msg);
}
+
validateVpcOfferingMultiqueueParameters(cmd.getPublicMultiqueueNumber(),
cmd.getPrivateGatewayMultiqueueNumber());
+
return createVpcOffering(vpcOfferingName, displayText,
supportedServices,
serviceProviderList, serviceCapabilityList, internetProtocol,
serviceOfferingId, provider, networkMode,
- domainIds, zoneIds, (enable ? State.Enabled : State.Disabled),
routingMode, specifyAsNumber, conserveMode, publicNetworkRate);
+ domainIds, zoneIds, (enable ? State.Enabled : State.Disabled),
routingMode, specifyAsNumber, conserveMode,
+ publicNetworkRate, cmd.getPublicMultiqueueNumber(),
cmd.getPrivateGatewayMultiqueueNumber());
+ }
+
+ private void validateVpcOfferingMultiqueueParameters(Integer
publicMultiqueueNumber, Integer privateGatewayMultiqueueNumber) {
+ String nonPositiveMultiqueueErrorMessage = "The only non-positive
value accepted by the parameter [%s] is [-1].";
+ String multiqueueGreaterThanMaximumErrorMessage = "[%s] parameter
cannot be greater than 256.";
+
+ if (publicMultiqueueNumber != null && publicMultiqueueNumber <= 0 &&
publicMultiqueueNumber != -1) {
+ throw new
InvalidParameterValueException(String.format(nonPositiveMultiqueueErrorMessage,
ApiConstants.PUBLIC_MULTIQUEUE_NUMBER));
+ }
+
+ if (publicMultiqueueNumber != null && publicMultiqueueNumber > 256) {
+ throw new
InvalidParameterValueException(String.format(multiqueueGreaterThanMaximumErrorMessage,
ApiConstants.PUBLIC_MULTIQUEUE_NUMBER));
+ }
+
+ if (privateGatewayMultiqueueNumber != null &&
privateGatewayMultiqueueNumber <= 0 && privateGatewayMultiqueueNumber != -1) {
+ throw new
InvalidParameterValueException(String.format(nonPositiveMultiqueueErrorMessage,
ApiConstants.PRIVATE_GATEWAY_MULTIQUEUE_NUMBER));
+ }
+
+ if (privateGatewayMultiqueueNumber != null &&
privateGatewayMultiqueueNumber > 256) {
+ throw new
InvalidParameterValueException(String.format(multiqueueGreaterThanMaximumErrorMessage,
ApiConstants.PRIVATE_GATEWAY_MULTIQUEUE_NUMBER));
+ }
Review Comment:
Another nit here: I noticed that the same validations are placed throughout
the workflows that involve validating the value being used for the multi queue
number. Do you think it's worth for us to create a small helper to centralize
these validations, or place them in a class that is achievable by the
validation flows?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]