Repository navigation
Re-reserve released NICs when a VM resyncs to Running to restore nics_count #14460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.22
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5432,6 +5432,7 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(final VMInstanceVO vm) { | |
| 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); | ||
| break; | ||
|
|
||
| case Destroyed: | ||
|
|
@@ -5456,6 +5457,20 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(final VMInstanceVO vm) { | |
| } | ||
| } | ||
|
|
||
| private void reconcileNicsForRunningVm(final VMInstanceVO vm) { | ||
| final VMInstanceVO runningVm = _vmDao.findById(vm.getId()); | ||
| if (runningVm == null || runningVm.getType() != VirtualMachine.Type.User || runningVm.getState() != State.Running || runningVm.getHostId() == null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does the issue impact DomainRouter ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't because if it's not userVM we return.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the VR should not impact the network garbage collector.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh misinterpreted your statement earlier - I thought you meant does the fix impact VRs - my bad 🤦
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's true indeed |
||
| || _nicsDao.listByVmId(runningVm.getId()).stream().noneMatch(nic -> nic.getState() == Nic.State.Allocated)) { | ||
| return; | ||
| } | ||
| final Host host = _hostDao.findById(runningVm.getHostId()); | ||
| final DataCenter dc = _entityMgr.findById(DataCenter.class, runningVm.getDataCenterId()); | ||
| final User user = _entityMgr.findById(User.class, User.UID_SYSTEM); | ||
| final Account account = _entityMgr.findById(Account.class, Account.ACCOUNT_ID_SYSTEM); | ||
| final ReservationContext context = new ReservationContextImpl(null, null, user, account); | ||
| _networkMgr.reconcileNicsForRunningVm(new VirtualMachineProfileImpl(runningVm), new DeployDestination(dc, null, null, host), context); | ||
| } | ||
|
|
||
| private void handlePowerOffReportWithNoPendingJobsOnVM(final VMInstanceVO vm) { | ||
| switch (vm.getState()) { | ||
| case Starting: | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.