Skip to content

network: restore released NIC state when a VM re-syncs Stopped/Stopping state - #14460

Draft
Pearl1594 wants to merge 2 commits into
4.22from
ghi14177-nic-reconcile-4.22
Draft

Pearl1594 wants to merge 2 commits into
4.22from
ghi14177-nic-reconcile-4.22

Conversation

@Pearl1594

@Pearl1594 Pearl1594 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR fixes: #14177

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

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

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.32%. Comparing base (d02adcd) to head (1bce999).

Files with missing lines Patch % Lines
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 84.61% 1 Missing and 1 partial ⚠️
...tack/engine/orchestration/NetworkOrchestrator.java 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14460   +/-   ##
=========================================
  Coverage     18.32%   18.32%           
- Complexity    16644    16651    +7     
=========================================
  Files          5939     5939           
  Lines        537768   537797   +29     
  Branches      65929    65932    +3     
=========================================
+ Hits          98551    98571   +20     
- Misses       428008   428016    +8     
- Partials      11209    11210    +1     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.42% <89.65%> (+<0.01%) ⬆️

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.

ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, vm.getDomainId(),
EventTypes.EVENT_VM_START, "Out of band VM power on", vm.getId(), getApiCommandResourceTypeForVm(vm).toString());
logger.info("VM {} is sync-ed to at Running state according to power-on report from hypervisor.", vm.getInstanceName());
reconcileNicsForRunningVm(vm);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need it in the stopped||stopping block? if the VM never reports as running again we have a spare nic in our nic count. should it be added to the start block instead.

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.

when a running vm is reported as stopped, cloudstack will send a command to force-stop it (I guess it is to ensure the vm is stopped) , and release the nic when done.

as far as I know, nics_count is not used any more to determine if the network need to be shutdown. the goal of this PR is to restore the nic state, not nics_count. PR title should be updated.

@DaanHoogland DaanHoogland Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Pearl1594 do you agree? can you update the PR title appropriately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, title seems apt @DaanHoogland

@DaanHoogland DaanHoogland changed the title Re-reserve released NICs when a VM resyncs to Running to restore nics_count network: restore released NIC state when a VM re-syncs Stopped/Stopping state Nov 4, 2026
@DaanHoogland
DaanHoogland force-pushed the ghi14177-nic-reconcile-4.22 branch from 99d9c27 to 9b81f09 Compare November 4, 2026 15:11
@DaanHoogland

Copy link
Copy Markdown
Contributor

ready for review, @Pearl1594 ?

@Pearl1594

Copy link
Copy Markdown
Contributor Author

Yes @DaanHoogland - ready for review/test. Thanks.

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

@DaanHoogland
DaanHoogland self-requested a review November 6, 2026 07:50
@DaanHoogland

Copy link
Copy Markdown
Contributor

clgtm

on second though I have my doubts. so I asked claude and let it generate some test code, I'll push here if you agree, @Pearl1594 .

@Pearl1594

Copy link
Copy Markdown
Contributor Author

go ahead @DaanHoogland

@boring-cyborg boring-cyborg Bot added component:integration-test Python Warning... Python code Ahead! labels Nov 6, 2026
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland 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.

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

self.assertEqual(self.get_nics_count(network_id), nics_count - 1, "nics_count should drop by one when the nic is released")

# 4 - bring the domain back out of band, a persistent domain is still defined and only needs a start
ssh_host.execute("virsh create %s || virsh start %s" % (domain_xml, vm_response.instancename))

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.

this may fail, afaik bridge might be removed when the last vm on the bridge is stopped.

@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NetworkGarbageCollector releases a network's VLAN while it still has live NICs

4 participants