Skip to content

Conversation

@viren-nadkarni
Copy link
Contributor

@viren-nadkarni viren-nadkarni commented Nov 6, 2025

Please see the comment below for PR description

@baermat
Copy link

baermat commented Nov 16, 2025

This PR adds more extensive calculations for MixedInstanceTypes for auto scaling groups, which are closer to what AWS does internally.
When a mixed instance types template is passed, the following should happen:

  • The base should be filled with on-demand instances
  • The remaining capacity up to desired should be filled with either on-demand or spot instances
    • This is determined by the passed percentage
  • All of this is measured in abstract units, not in instances. Instances are assigned a certain unit value, which can lead to "extra ceil rounding instances" . If e.g. an instances has weight 4 units, and desired capacity is 8, but the calculation calls for 2u + 3u + 3u, it results in 3 instances, not 2 4u+4u (see test for details).

Limitations: The function currently expects a "prioritized" strategy for the OnDemandAllocationStrategy. Adding more strategies would have been out of scope, so this was left as is.

@baermat
Copy link

baermat commented Nov 16, 2025

@viren-nadkarni please start the workflows, review the changes and if ready mark as ready for review please :)

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.04%. Comparing base (0d4bc17) to head (1734892).
⚠️ Report is 38 commits behind head on master.

Files with missing lines Patch % Lines
moto/autoscaling/models.py 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9444      +/-   ##
==========================================
+ Coverage   93.02%   93.04%   +0.01%     
==========================================
  Files        1292     1295       +3     
  Lines      116184   116441     +257     
==========================================
+ Hits       108083   108341     +258     
+ Misses       8101     8100       -1     
Flag Coverage Δ
servertests 28.89% <3.12%> (+0.04%) ⬆️
unittests 93.01% <96.87%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@viren-nadkarni viren-nadkarni marked this pull request as ready for review November 18, 2025 12:10
Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for adding this feature to Moto @baermat and @viren-nadkarni!

@bblommers bblommers added this to the 5.1.18 milestone Nov 18, 2025
@bblommers bblommers merged commit 6085b0b into getmoto:master Nov 18, 2025
65 checks passed
@viren-nadkarni viren-nadkarni deleted the autoscaling-weights branch November 19, 2025 05:22
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