Conversation
# Conflicts: # server/src/main/java/com/cloud/vm/UserVmManagerImpl.java # ui/src/config/section/network.js
There was a problem hiding this comment.
🔵 Needs a closer look
It touches VM lifecycle/network persistence plus API/UI surfaces, and the impact on runtime behavior and query/load characteristics needs careful human validation and end-to-end testing.
Pull request overview
Persists the effective network rate (bandwidth throttling) for NICs and Guest Networks into their respective *_details tables, and exposes these values via CloudStack API responses and UI detail views.
Changes:
- Persist NIC network rate into
nic_detailson NIC hot-plug and refresh persisted values on VM start. - Persist Guest Network network rate into
network_detailson network creation and on guest network offering updates. - Expose
networkratethrough API (NicResponse,NetworkResponse) and display it in the UI (Guest Network details + VM NIC expanded row; plus Service Offering columns/details).
File summaries
| File | Description |
|---|---|
| ui/src/views/network/NicsTable.vue | Displays NIC networkrate in the expanded NIC details (Admin/DomainAdmin only). |
| ui/src/config/section/offering.js | Adds networkrate to compute service offering list columns and details fields. |
| ui/src/config/section/network.js | Adds networkrate to Guest Network detail fields. |
| server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | Persists NIC effective rate on hot-plug and refreshes NIC rates on VM start. |
| server/src/main/java/com/cloud/network/NetworkServiceImpl.java | Upserts Guest Network rate into network_details when updating the guest network offering. |
| server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java | Populates per-NIC networkrate in VM responses from nic_details. |
| server/src/main/java/com/cloud/api/ApiResponseHelper.java | Populates networkrate for Network and NIC responses from *_details. |
| server/src/main/java/com/cloud/api/ApiDBUtils.java | Adds DAO wiring + helper to fetch NIC details by key. |
| api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java | Introduces networkrate field on NIC API response. |
| api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java | Introduces networkrate field on Network API response. |
| api/src/main/java/org/apache/cloudstack/api/ApiConstants.java | Adds UNLIMITED string constant for persisted rate representation. |
| engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java | Persists Guest Network rate into network_details during network setup. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| NicDetailVO nicNetworkRateDetail = ApiDBUtils.findNicDetailByName(userVm.getNicId(), ApiConstants.NETWORKRATE); | ||
| if (nicNetworkRateDetail != null) { | ||
| nicResponse.setNetworkRate(nicNetworkRateDetail.getValue()); | ||
| } |
| @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; |
| @Inject | ||
| private NicDetailsDao nicDetailsDao; | ||
| @Inject |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14055 +/- ##
=========================================
Coverage 19.77% 19.78%
- Complexity 19989 19997 +8
=========================================
Files 6371 6371
Lines 575899 575949 +50
Branches 70495 70502 +7
=========================================
+ Hits 113912 113963 +51
+ Misses 449563 449560 -3
- Partials 12424 12426 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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)allocateNetworksForVm()callsrefreshNicNetworkRates()after NICs are created in the DBaddNicToVm()persists the rate immediately after allocationStartVMCmd):refreshNicNetworkRates()refreshes all NIC rates so stale values are corrected when the network offering changes between stop/start cyclesNetworkOrchestrator.removeNic()andremoveNics()clean upnic_detailsco-located with the_nicDao.remove()call, respecting thepreserveNicsguardPersistence — Guest Network (
network_details)NetworkOrchestrator.setupNetwork()callssaveNetworkRateInDetails()after the network record is committedNetworkServiceImpl.updateGuestNetwork()upserts the rate inside the offering-change transactionAPI
NicResponse: newnetworkratefield (since = "4.24.0") populated fromnic_detailsNetworkResponse: newnetworkratefield (since = "4.21.0") populated fromnetwork_detailsApiResponseHelper: reads rate detail for both NIC and Network responsesUI
networkrateadded to the fields array innetwork.jsNicsTable.vue):networkrateshown under the Admin/DomainAdmin guard alongsidebroadcasturiandisolationuriDesign notes
"unlimited"when the offering has no limitNicVOandNetworkVOuse soft-delete (removed = NOW()), soON DELETE CASCADEon the FK never fires — cleanup is explicitrefreshNicNetworkRates()usesNetworkModelImpl.getNetworkRate()which resolves the current offering dynamically, matching what the hypervisor enforces when rebuilding domain XMLTest plan
nic_detailshas the ratenic_detailsentry creatednic_detailsreflects the new ratenic_detailsrows are removedlistNicsresponse includesnetworkratelistNetworksresponse includesnetworkrate