Skip to content

server: keep collecting VM network stats after a non DirectAttached NIC - #14142

Open
nagaboinaramgopal wants to merge 1 commit into
apache:4.20from
nagaboinaramgopal:fix/vmnetworkstats-break
Open

nagaboinaramgopal wants to merge 1 commit into
apache:4.20from
nagaboinaramgopal:fix/vmnetworkstats-break

Conversation

@nagaboinaramgopal

@nagaboinaramgopal nagaboinaramgopal commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

When a KVM VM is stopped, collectVmNetworkStatistics records usage for its NICs on DirectAttached (shared) networks. For a NIC on any other network it ran break, which ends the whole loop, so a shared network NIC ordered after an isolated one never gets its statistics recorded. The comment says the intent is to skip only that NIC, so this changes break to continue.

The same code is on 4.20, 4.22 and main, so this targets 4.20.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Added a test to UserVmManagerImplTest that feeds collectVmNetworkStatistics stats for an isolated NIC followed by a shared network NIC and checks the shared NIC's user_statistics row is updated. It fails against the current code and passes with the fix. The class passes (182 tests).

Also verified on a live 4.23 KVM environment with the same change: a VM with NIC 0 on an isolated network and NIC 1 on a shared network (192.16.98.4), running a few minutes and then stopped.

Before, the stop runs the collection but writes nothing for the shared NIC:

Collect vm network statistics from host before stopping Vm
user_statistics for the VM: (no rows)

After, the shared NIC's usage is recorded on stop:

Collect vm network statistics from host before stopping Vm
user_statistics for the VM: network 231 (shared), 192.16.98.4, bytes received 320

How did you try to break this feature and the system with this change?

NICs on networks that are not DirectAttached are still skipped, and a VM whose NICs are all on shared networks behaves as before. Only the NICs after the first skipped one are affected, which now get their statistics recorded.

collectVmNetworkStatistics used break when a NIC was not on a DirectAttached
network, which ended the whole loop. A DirectAttached (shared network) NIC
ordered after an isolated one therefore never had its statistics recorded when
the VM was stopped. Skip only that NIC.

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19223

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.38%. Comparing base (b93f603) to head (94cd268).
⚠️ Report is 2 commits behind head on 4.20.

Additional details and impacted files
@@             Coverage Diff              @@
##              4.20   #14142       +/-   ##
============================================
+ Coverage     4.14%   16.38%   +12.24%     
- Complexity       0    13604    +13604     
============================================
  Files          405     5669     +5264     
  Lines        33073   501475   +468402     
  Branches      5903    60913    +55010     
============================================
+ Hits          1370    82172    +80802     
- Misses       31527   410082   +378555     
- Partials       176     9221     +9045     
Flag Coverage Δ
uitests 4.14% <ø> (ø)
unittests 17.25% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16977)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53140 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14142-t16977-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py

@nagaboinaramgopal

Copy link
Copy Markdown
Contributor Author

Thanks @weizhouapache for the review and the smoke run. This needs a second review; could someone take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants