Skip to content

considder stopped VMs on autoscale - #14284

Draft
DaanHoogland wants to merge 1 commit into
4.22from
ghi14185-autoscaleStartExcessFix
Draft

DaanHoogland wants to merge 1 commit into
4.22from
ghi14185-autoscaleStartExcessFix

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR...

Fixes: #14185

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):

How Has This Been Tested?

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

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.00%. Comparing base (2e63c60) to head (9c2bf24).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14284   +/-   ##
=========================================
  Coverage     18.00%   18.00%           
- Complexity    16219    16222    +3     
=========================================
  Files          5936     5936           
  Lines        535716   535716           
  Branches      65596    65596           
=========================================
+ Hits          96459    96478   +19     
+ Misses       428268   428248   -20     
- Partials      10989    10990    +1     
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 19.08% <100.00%> (+<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.

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@DaanHoogland
DaanHoogland requested review from sudo87 and a balanced review from Copilot and removed request for sudo87 October 22, 2026 09:55

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

This PR addresses autoscale groups leaking stopped VMs after a failed start by ensuring stopped instances are considered “errored” for scaling decisions and by handling the unchecked exception thrown during VM start.

Changes:

  • Update autoscale scale-up error handling to catch CloudRuntimeException thrown by VM start.
  • Treat VirtualMachine.State.Stopped as an errored state for autoscale VM group instance counting.
  • Add regression/unit tests covering the stopped/errored instance counting and scale-up cleanup behavior.
File Description
server/​src/​main/​java/​com/​cloud/​network/​as/​AutoScaleManagerImpl.java Adjusts scale-up exception handling to react to unchecked start failures.
server/​src/​test/​java/​com/​cloud/​network/​as/​AutoScaleManagerImplTest.java Adds regression test ensuring failed starts trigger VM cleanup and state reset.
engine/​schema/​src/​main/​java/​com/​cloud/​network/​as/​dao/​AutoScaleVmGroupVmMapDaoImpl.java Counts Stopped VMs alongside Error as “errored” instances.
engine/​schema/​src/​test/​java/​com/​cloud/​network/​as/​dao/​AutoScaleVmGroupVmMapDaoImplTest.java Adds test validating Stopped is included in errored instance count query.

Review effort: Lite

break;
}
} catch (ServerApiException e) {
} catch (CloudRuntimeException e) {
Comment on lines +1552 to +1553
Mockito.doThrow(new CloudRuntimeException(String.format("Unable to start a VM [%s] due to [Resource unavailable].", virtualMachineId)))
.when(userVmMgr).startVirtualMachine(virtualMachineId, null, new HashMap<>(), null);

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

thanks @DaanHoogland for the changes, I think it's fine to add Stopped state as well in threshold. Just have few ques:

  1. Can we specifically target Stopped Instances which failed to Start. Currently any instances which are in stopped state in the group will be taken into account, even the ones without start failure.
  2. Setting description and log message need to be changed

@nvazquez nvazquez modified the milestones: 4.22.2, 4.22.3 Nov 9, 2026

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.

Autoscale: infinite scale-up when VMs fail to START (Stopped) — #11244 guard only counts Error state

4 participants