You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "sudo87 (via GitHub)" <gi...@apache.org> on 2026/09/04 06:02:13 UTC
[PR] feat: persist and expose effective network rate for NIC and Guest Network [cloudstack]
sudo87 opened a new pull request, #14055:
URL: https://github.com/apache/cloudstack/pull/14055
## Summary
Persists the effective network rate (bandwidth throttling) for both NICs and Guest Networks in their respective detail tables, and exposes the values through the API and UI.
### What changed
**Persistence — NIC (`nic_details`)**
- On VM deploy: `allocateNetworksForVm()` calls `refreshNicNetworkRates()` after NICs are created in the DB
- On NIC hot-plug: `addNicToVm()` persists the rate immediately after allocation
- On VM start (`StartVMCmd`): `refreshNicNetworkRates()` refreshes all NIC rates so stale values are corrected when the network offering changes between stop/start cycles
- On NIC/VM removal: `NetworkOrchestrator.removeNic()` and `removeNics()` clean up `nic_details` co-located with the `_nicDao.remove()` call, respecting the `preserveNics` guard
**Persistence — Guest Network (`network_details`)**
- On network create: `NetworkOrchestrator.setupNetwork()` calls `saveNetworkRateInDetails()` after the network record is committed
- On network offering update: `NetworkServiceImpl.updateGuestNetwork()` upserts the rate inside the offering-change transaction
**API**
- `NicResponse`: new `networkrate` field (`since = "4.24.0"`) populated from `nic_details`
- `NetworkResponse`: new `networkrate` field (`since = "4.21.0"`) populated from `network_details`
- `ApiResponseHelper`: reads rate detail for both NIC and Network responses
**UI**
- Guest Network detail page: `networkrate` added to the fields array in `network.js`
- VM NIC expanded row (`NicsTable.vue`): `networkrate` shown under the Admin/DomainAdmin guard alongside `broadcasturi` and `isolationuri`
### Design notes
- Rate is stored as a string: a positive integer (Mb/s) or `"unlimited"` when the offering has no limit
- `NicVO` and `NetworkVO` use soft-delete (`removed = NOW()`), so `ON DELETE CASCADE` on the FK never fires — cleanup is explicit
- `refreshNicNetworkRates()` uses `NetworkModelImpl.getNetworkRate()` which resolves the current offering dynamically, matching what the hypervisor enforces when rebuilding domain XML
## Test plan
- [ ] Deploy a VM on a network with throttling configured — verify `nic_details` has the rate
- [ ] Hot-plug a NIC — verify `nic_details` entry created
- [ ] Update the network offering on an existing network, stop/start the VM — verify `nic_details` reflects the new rate
- [ ] Destroy a VM — verify `nic_details` rows are removed
- [ ] `listNics` response includes `networkrate`
- [ ] `listNetworks` response includes `networkrate`
- [ ] Guest Network detail page shows Network Rate field
- [ ] VM details NIC expanded row shows Network Rate (Admin/DomainAdmin only)
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: persist and expose effective network rate for NIC and Guest Network [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #14055:
URL: https://github.com/apache/cloudstack/pull/14055#issuecomment-5536481103
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/14055?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 3.53%. Comparing base ([`44ab7dd`](https://app.codecov.io/gh/apache/cloudstack/commit/44ab7dd85d4e90a6f429e4446b169e207e07ffaf?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c8ac2a0`](https://app.codecov.io/gh/apache/cloudstack/commit/c8ac2a008b2795962af42b212ae97f1e2cebe63f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (44ab7dd) and HEAD (c8ac2a0). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (44ab7dd) | HEAD (c8ac2a0) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #14055 +/- ##
=============================================
- Coverage 19.77% 3.53% -16.25%
=============================================
Files 6371 487 -5884
Lines 575899 41863 -534036
Branches 70495 7912 -62583
=============================================
- Hits 113912 1479 -112433
+ Misses 449563 40170 -409393
+ Partials 12424 214 -12210
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/14055/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/14055/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.53% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/14055/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cloudstack/pull/14055?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: persist and expose effective network rate for NIC and Guest Network [cloudstack]
Posted by "sudo87 (via GitHub)" <gi...@apache.org>.
sudo87 closed pull request #14055: feat: persist and expose effective network rate for NIC and Guest Network
URL: https://github.com/apache/cloudstack/pull/14055
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: persist and expose effective network rate for NIC and Guest Network [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #14055:
URL: https://github.com/apache/cloudstack/pull/14055#discussion_r3931343265
##########
server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java:
##########
@@ -447,6 +448,10 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
.collect(Collectors.toList());
nicResponse.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
+ NicDetailVO nicNetworkRateDetail = ApiDBUtils.findNicDetailByName(userVm.getNicId(), ApiConstants.NETWORKRATE);
+ if (nicNetworkRateDetail != null) {
+ nicResponse.setNetworkRate(nicNetworkRateDetail.getValue());
+ }
Review Comment:
This adds a DAO lookup per NIC while building VM responses (`findNicDetailByName(...)` inside the NIC loop). For VMs with multiple NICs (and especially listVms across many VMs), this can introduce an N+1 query pattern and increase DB load.
##########
api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java:
##########
@@ -311,6 +311,10 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
@Param(description = "MTU configured on the network VR's private interfaces")
private Integer privateMtu;
+ @SerializedName(ApiConstants.NETWORKRATE)
+ @Param(description = "Network rate (in Mb/s) configured for the Guest interface of this network", since = "4.24.0")
+ private String networkRate;
Review Comment:
PR description says `NetworkResponse.networkrate` is `since = "4.21.0"`, but the annotation here declares `since = "4.24.0"`. Please align the `since` version with the intended release/API contract (either update this annotation or correct the PR description).
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -524,6 +525,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Inject
private NicDao _nicDao;
@Inject
+ private NicDetailsDao nicDetailsDao;
+ @Inject
Review Comment:
Injected DAO field name `nicDetailsDao` doesn’t follow the surrounding `_camelCase` convention used for injected dependencies in this class (e.g. `_nicDao`, `_rulesMgr`). This inconsistency makes the class harder to scan and is easy to avoid by renaming to match the established pattern.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org