Skip to content

Allow a service offering to set its own overcommit ratio - #14112

Open
bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:per-offering-overprovisioning
Open

bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:per-offering-overprovisioning

Conversation

@bhouse-nexthop

@bhouse-nexthop bhouse-nexthop commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Lets a service offering set its own overcommit ratio, overriding whatever its cluster is set to.

The problem. A cluster's overcommit ratio applies to every VM on it, and the per-VM detail that
records it was force-synced to the cluster's value on every start, so there was no way to exempt
anything. On a cluster overcommitted for workloads that are idle most of the time, infrastructure
VMs are overcommitted too, whether or not that is safe for them.

How it works. An offering may set cpuOvercommitRatio or memoryOvercommitRatio in its details

  • the same detail keys already used at cluster and VM scope. Absent, the cluster's ratio applies as
    before, so nothing changes for existing offerings.

The value means the same thing at every scope: how far a VM's declared size is inflated relative to
what it really holds.

Value Meaning
1 Not overcommitted. The VM is charged its full real footprint and holds all of it
4 Oversubscribed four times
absent Inherit the cluster

Values below 1 would mean reserving more than the VM asked for. That is a different feature and is
rejected, rather than being reachable by mistyping 1 as 0.1 - which would have charged the VM
ten times its size. An offering may declare a ratio higher than its cluster's; the value is absolute
rather than relative, so there is no contradiction in that, and it is logged.

Memory really is held. An offering with a memory ratio of 1 also has free page reporting and
balloon auto-deflate turned off for its VMs, so the guest does not lend unused memory back to the
host. Without that the exemption would hold in the books only. The balloon device itself stays, so
memory statistics are unaffected. This applies only when the offering has explicitly asked - an
offering that says nothing inherits its cluster, and a cluster with no overcommit configured is the
default everywhere.

UI

Two optional fields on the compute offering form, admin-only and blank by default. Blank means
inherit the cluster, so an existing offering is unaffected and a new one behaves as before unless
the field is filled in. Values below 1 are rejected in the browser as well as on the server.

The offering details tab shows both.

Two adjacent fixes the new fields would otherwise have tripped over:

  • serviceofferingdetails[0] was hardcoded for ImplicitDedicationMode in the add and clone views,
    so any second detail written at index 0 silently replaced it. Both now use a running index.
  • the clone view copied the whole details map into the external details widget, which would have
    re-submitted these keys as External:cpuOvercommitRatio. It now lifts them into the new fields.

The details tab also no longer renders an empty row for an offering detail the offering does not
have.

updateServiceOffering accepts only externaldetails, so the ratios are set at create or clone
time, matching what the API supports.

Also fixes a latent accounting bug

Capacity is counted in cluster-overcommitted units: totals are stored raw and multiplied by the
cluster ratio when read. The periodic recalculation in updateCapacityForHost already scaled each
VM by the ratio it started under, but the incremental paths did not - they charged the raw request.

The two agree only while every VM shares its cluster's ratio, which was true because of the
force-sync described above. It becomes observable as soon as ratios differ, which is what this
feature causes, so it is fixed here as the first commit. No behaviour change while ratios are
uniform.

Everything that asks "does this host have room" now asks in the same units the charge will use, so a
VM cannot pass a capacity check and then fail to start.

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

How Has This Been Tested?

  • CapacityManagerScaleToClusterUnitsTest - 7 cases on scaling a request into capacity units: a VM
    inheriting its cluster is charged as requested; one exempted from an overcommitted cluster is
    charged its full share; one left over from an earlier cluster setting is rescaled; nonsense values
    fall back.
  • VirtualMachineManagerOverCommitTest - 15 cases on what an offering asks for and what gets
    recorded on the VM, including the two review findings below and the rule for when memory reclaim
    is turned off.
  • ConfigurationManagerOverCommitDetailTest - 7 cases on validation, including the floor at 1.
  • LibvirtVMDefTest - the domain XML with reclaim disabled: no freePageReporting, no
    autodeflate, balloon device and statistics still present.

Full mvn test on engine/components-api, engine/orchestration, server and the KVM plugin with
checkstyle and license checks enabled: 0 failures.

UI: vue-cli-service lint over the whole tree and a production build, both clean.

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

Adversarial review found two defects that made the branch worse than what it replaced. Both fixed:

  • The headline case was not charged. The ratio was recorded on the VM only when it differed from
    1, so an offering asking for a ratio of 1 on an overcommitted cluster recorded nothing and the
    charge fell back to the cluster's ratio - a tenth of what the VM occupies at a factor of 10. The
    memory pinning still applied, so the host really did hold memory it was not charged for. Ten such
    VMs would fit where one should.
  • Memory reclaim was disabled on every VM of every default installation. The trigger was "the
    resolved ratio is 1", and clusters ship with a ratio of 1, so on upgrade every KVM guest would
    have lost free page reporting at its next start on installations that opted into nothing. Now
    triggers on the offering having explicitly asked.

Also checked: rounding against updateCapacityForHost (brute-forced across ~140k RAM and CPU
combinations - identical whenever the detail is present); the ordering of the capacity charge
against the detail being written; unreadable and out-of-range values on both the offering and the VM
detail; and that the charge and the refund use the same figure.

Known remaining gaps, all self-healing at the next capacity recalculation and worth calling out
rather than hiding: a cross-cluster migration rewrites the VM's ratio before the source host is
refunded, so the refund can use a different ratio to the charge; and a scale-up does not re-resolve
the ratio, so a VM keeps the ratio from its last start until it next stops or migrates.

@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.65657% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.84%. Comparing base (a0518a9) to head (6d432e7).

Files with missing lines Patch % Lines
...n/java/com/cloud/capacity/CapacityManagerImpl.java 43.13% 28 Missing and 1 partial ⚠️
.../cloud/configuration/ConfigurationManagerImpl.java 79.48% 6 Missing and 2 partials ⚠️
.../com/cloud/vm/VirtualMachineManagerOverCommit.java 88.70% 1 Missing and 6 partials ⚠️
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 25.00% 6 Missing ⚠️
...om/cloud/deploy/DeploymentPlanningManagerImpl.java 54.54% 2 Missing and 3 partials ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 5 Missing ⚠️
...om/cloud/hypervisor/kvm/resource/LibvirtVMDef.java 66.66% 1 Missing and 3 partials ⚠️
.../main/java/com/cloud/capacity/CapacityManager.java 66.66% 3 Missing ⚠️
...ervisor/kvm/resource/LibvirtComputingResource.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14112      +/-   ##
============================================
+ Coverage     20.82%   20.84%   +0.01%     
- Complexity    20969    21010      +41     
============================================
  Files          6054     6055       +1     
  Lines        549013   549212     +199     
  Branches      73365    73406      +41     
============================================
+ Hits         114354   114488     +134     
- Misses       421268   421321      +53     
- Partials      13391    13403      +12     
Flag Coverage Δ
uitests 3.86% <ø> (-0.01%) ⬇️
unittests 22.28% <65.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.

@DaanHoogland DaanHoogland added this to the 24.0 milestone Sep 10, 2026
@DaanHoogland
DaanHoogland requested review from shwstppr and vishesh92 and removed request for shwstppr September 10, 2026 08:56
@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch from 35b3a98 to 51c29f3 Compare September 10, 2026 14:02
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch from a0f4f34 to 132c151 Compare September 16, 2026 12:40
@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch from 132c151 to a6d3b42 Compare October 22, 2026 13:17
@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 no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19740

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

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

this deserves more attention than I have right now.

  • I skimmed the code and looks ok on first sight
  • The tests in separate files for a single class are a sign that either that class needs splitting or the tests should be consolidated
  • I have no clear picture of the functional consequences yet, @weizhouapache @sureshanaparti @NuxRo can you have a look please?

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Test report: per-offering overcommit ratios

Environment

  • A CloudStack 24.0 (main) build with this PR applied, alongside some of my other open PRs, including Add 'balancedweighted' VM allocation algorithm #14109.
  • In that build the PR is combined with my other open PRs, which needed some conflicts resolved. So this covers the same code as merged alongside them, not the exact PR head.
  • Three KVM hosts on Ubuntu 24.04 (libvirt 10.0.0, QEMU 8.2.2), nested virtualisation; Ceph RBD primary storage; one management server.
  • Cluster overcommit set for the test: cpu.overprovisioning.factor=4, mem.overprovisioning.factor=2 (cluster scope).
  • Offerings:
    • exempt: 1 vCPU, 1000 MHz, 1024 MB, with cpuOvercommitRatio=1 and memoryOvercommitRatio=1 as service offering details;
    • normal: the same size, no details.
  • Test VMs are CirrOS, deployed with hostid= to one host. Capacity figures are from op_host_capacity for that host.

1. Capacity charged at start

memory used CPU used
before 10752 MiB 6000 MHz
+ exempt VM +2048 MiB +4000 MHz
+ normal VM +1024 MiB +1000 MHz

Capacity is counted in cluster-overcommitted units. So the exempt VM is charged its full size at the cluster's ratios (1024 × 2 and 1000 × 4), and the normal VM at its nominal size.

2. The periodic and incremental paths agree

  • Across one periodic capacity recalculation (capacity.check.period=300000; Executing cpu/ram capacity update at 12:13:24), used memory and CPU were unchanged.
  • Stop, then start on the same host:
    • exempt stopped: used −2048 MiB / −4000 MHz, reserved +2048 MiB / +4000 MHz. Started: back to exactly the earlier figures.
    • normal stopped: used −1024 / −1000, reserved +1024 / +1000. Started: back exactly.
  • One more periodic recalculation: still no change. No drift.

3. VM details

  • exempt: cpuOvercommitRatio=1.0, memoryOvercommitRatio=1.0, memoryReclaimDisabled=true
  • normal: cpuOvercommitRatio=4.0, memoryOvercommitRatio=2.0. No memoryReclaimDisabled.

4. libvirt

exempt: <memballoon model='virtio'>
        balloon.current=1048576 balloon.maximum=1048576 balloon.available=971668 balloon.rss=260484
normal: <memballoon model='virtio' autodeflate='on' freePageReporting='on'>
        balloon.current=524288 balloon.maximum=524288 balloon.available=390036 balloon.rss=279240
  • The exempt VM keeps its balloon device, so balloon statistics are still reported, but it has no auto-deflate and no free-page reporting.
  • It also gets its full 1 GiB as current memory. The normal VM gets 512 MiB, which is the existing behaviour of an overcommitted cluster.

5. Validation

  • memoryOvercommitRatio=0.5: refused, Service offering detail memoryOvercommitRatio must be at least 1, got [0.5]. 1 means the offering is not overcommitted; ...
  • =abc: refused, ... must be a number, got [abc].
  • =0: refused, ... must be at least 1, got [0].
  • =8 (above the cluster's 2) was accepted. A VM started on it logged:
    Service offering 23 declares memoryOvercommitRatio of 8.0, more than its cluster's 2.0, so its VMs are oversubscribed further than the cluster default.
    

6. Placement uses the same units

  • I filled the host with exempt VMs using hostid=: 4096 MB exempt VMs until refused, then 1024 MB ones.
  • Memory used went 13824 → 22016 → … → 54784 MiB, +8192 per 4 GB VM. The 6th 4 GB VM was refused. One 1 GB VM fitted (56832 MiB), and the next was refused.
  • Both refusals happened at planning. No StartCommand was sent, and the VMs ended in Error with no host. The planner asked in charge units:
    Checking if host: Host {..."host1"...} has enough capacity for requested CPU: 4000 and requested RAM: (2.00 GB) 2147483648 , cpuOverprovisioningFactor: 4.0
    Free RAM: (1.23 GB) 1322369024 , Requested RAM: (2.00 GB) 2147483648
    Host does not have enough RAM available, cannot allocate to this host.
    
    That was a 1 GB exempt VM, asked for as 2 GB.
  • The 6 VMs that did start used little real memory: the host still had about 17 GB available.

7. A cluster with no overcommit is unaffected

  • With the cluster back at 1 / 1, a normal VM had <memballoon model='virtio' autodeflate='on' freePageReporting='on'>.
  • It had no overcommit or reclaim details. This was the review regression.

8. The offering form

  • I did not drive the browser. The deployed UI bundle does contain the new fields.
  • I sent the API calls exactly as the updated add and clone views build them:
    • Add, with ImplicitDedicationPlanner (mode Strict) plus both ratios at running indexes 0, 1 and 2: all three details were stored (ImplicitDedicationMode=Strict, cpuOvercommitRatio=1, memoryOvercommitRatio=1). The same request with two details both at index 0, which is what the old hard-coded index produced, kept only one.
    • Clone, with the ratios lifted out of the details map into serviceofferingdetails: the clone has the same three details and no External: keys. For comparison, the old view's request, with the whole details map in externaldetails, stored External:cpuOvercommitRatio=1, External:memoryOvercommitRatio=1, External:ImplicitDedicationMode=Strict.

Result: pass.

  • Exempt VMs are charged and placed in the same units: the periodic, start/stop and planning paths agree.
  • Their memory is not lent back to the host.
  • Invalid ratios are refused.
  • A default install keeps free-page reporting.

Not covered

  • The UI forms in a browser.
  • Non-KVM hypervisors, and changing a cluster's ratio while exempt VMs are running.
  • Scaling an exempt VM.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

@DaanHoogland thanks, and sorry it took a while to answer the rest of your review point by point.

Separate test files. You were right about two of the three. CapacityManagerScaleToClusterUnitsTest and ConfigurationManagerOverCommitDetailTest each tested a single method of a class that already has a main test file, so I've moved them into CapacityManagerImplTest and ConfigurationManagerImplTest (27b21a1). The tests themselves are unchanged. Only their names changed, so they say which method they cover. The count is the same before and after (14 moved, 897 in the capacity, allocator, planner, configuration, VM manager and KVM test classes, all passing). VirtualMachineManagerOverCommitTest stays where it is: after your earlier inline comment the logic was moved into its own class, VirtualMachineManagerOverCommit, and that file is that class's test. I've also merged main into the branch to clear the conflict, which was only in PendingReleaseNotes.

Functional consequences

  • What an operator sees: two optional compute offering fields, CPU and memory overcommit ratio. In the API they are the cpuOvercommitRatio / memoryOvercommitRatio keys of serviceofferingdetails, the same keys used at cluster and VM scope. They are checked when the offering is created: anything that isn't a number, or is below 1, is rejected. A value higher than the cluster's is allowed and logged when a VM starts.
  • Default behaviour: if an offering doesn't set the detail, the VM runs at its cluster's ratio, exactly as today. The planner's request scaling returns the request unchanged, no memory-reclaim flag is written, and the VM's recorded ratio is the cluster's, so the start/stop charge equals the request.
  • Capacity accounting: capacity is still counted in the cluster's overcommitted units. A VM whose offering sets its own ratio is charged size / offeringRatio * clusterRatio. So a ratio-1 VM on a 4x cluster takes 4x the units of a same-sized neighbour, which means it really holds its full size. The ratio is resolved when the VM starts or migrates and recorded on the VM. Start, stop and the periodic recalculation all read that recorded value, so they agree. While I was there I fixed a latent mismatch: start/stop used to charge the raw size, while the recalculation already scaled by the VM's recorded ratio. Those differed whenever the cluster ratio had been changed under running VMs.
  • Planner: the per-host capacity check (checkIfHostHasCpuCapabilityAndCapacity, used by the host allocators, router placement and starting a VM on a chosen host) and the last-host check in planDeployment both ask in the same scaled units, so a VM that passes the check is charged the same amount when it starts. The cluster-level pre-filtering in FirstFitPlanner (cluster ordering and the disable thresholds) still uses the offering's nominal size, as before. The per-host check is the one that decides.
  • KVM: for an offering with a memory ratio of 1, its VMs get autodeflate/freePageReporting turned off on the balloon, so the guest doesn't hand memory back to the host. The balloon device stays, so memory stats still work. VMs on offerings without the detail get the same domain XML as before.
  • Upgrade / existing VMs: there is no schema change and no data migration. Existing offerings have no detail, so nothing changes for them. An offering's ratio takes effect when one of its VMs starts or migrates. A live scale keeps the ratio the VM was started under until it next starts or migrates. The one visible change for existing VMs is the accounting fix above: on a cluster whose ratio was changed after its VMs started, start/stop now charge what the periodic recalculation would have converged to anyway.

The lab test of all this is in the earlier report.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch from 27b21a1 to 8b6b24f Compare November 24, 2026 17:24
@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch 3 times, most recently from c1231ef to 28ca1da Compare November 24, 2026 17:43
@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main and squashed into one commit (28ca1da). The only conflict was in ConfigurationManagerImplTest, where main's new updateConfiguration tests and this PR's ratio-validation tests sit at the same place. Both are kept.

Another review pass found a few holes, now fixed in the same commit:

case before now
live migration, or a start retried, into a cluster with another ratio the VM's ratio detail is rewritten before the old host is released, so the release didn't match the charge until the next capacity recalculation the start/stop charge and release depend only on the offering and the host's cluster, the same scaling the allocator uses, so a release always matches its charge
live scale to an offering with another ratio the host check asked for the raw size change, and the charge and min memory/speed used the old ratio all three use the new offering's ratio
cpuOvercommitRatio=NaN or Infinity accepted, so the VM was charged zero rejected when the offering is created, and ignored at start and placement
a domain admin setting a ratio on an offering allowed through the API (the UI only shows the fields to root admins) root admin only; a clone may keep the source's ratio unchanged
the ratio key in another case, e.g. MemoryOvercommitRatio stored as given, and read by the VM side but not by capacity stored under the canonical name
memoryReclaimDisabled VM detail shown to users hidden detail, set again at every start

Tests: VirtualMachineManagerOverCommitTest, VirtualMachineManagerImplTest, CapacityManagerImplTest, ConfigurationManagerImplTest, DeploymentPlanningManagerImplTest and UserVmManagerImplTest pass. LibvirtVMDefTest and LibvirtComputingResourceTest passed after the rebase; the fixes don't touch KVM.

Known limits:

  • Some capacity checks still use the offering's raw size: the planner's cluster/pod ordering, the cluster disable-threshold check, rolling maintenance, DRS and the CKS pre-checks. For a VM that inherits its cluster's ratio, that is unchanged from today. For an offering with its own ratio, they are an approximation. The host allocator check and the charge itself are exact.
  • If a cluster's ratio is changed under running VMs, the periodic recalculation (which scales by the ratio each VM started under) and a stop's release can differ until the next recalculation.
  • A live scale that changes the memory exemption only takes effect on the domain at the next start.
  • Cloning an offering and clearing a ratio field still copies the source's ratio. That is how cloneServiceOffering treats details it isn't given.

@DaanHoogland your test-file and functional points are answered in my comment of 2026-11-13. @weizhouapache @sureshanaparti @NuxRo a look at the functional side would still help, if you have time.

bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Nov 24, 2026
Carries the amended upstream version of "Allow a service offering to
set its own overcommit ratio" (apache#14112).

- Charge and release a VM by its offering's ratio against the cluster
  of the host it is on, instead of by the ratio recorded on the VM. A
  release then always matches the charge it undoes, after a
  migration, a retried start or a cluster ratio change.
- Live scale reconfigures the VM at the new offering's ratio and
  records that ratio on the VM. The capacity check asks for the change
  in the charge, which is scaled by each offering's ratio.
- Reject NaN and Infinity as offering ratios; treat them as unset if
  already stored.
- Only root admins may set the ratios when creating an offering (and,
  where cloning exists, change them on a clone). Ratio keys are stored
  under their canonical name.
- memoryReclaimDisabled is no longer shown to users.

Bundle-only, for offerings already in use:
- Offerings created by the previous code keep the ratio keys as typed.
  The ratios are read case-insensitively wherever the details are
  looked up in Java, so those offerings keep their ratio. Where two
  keys differ only in case, the canonical one wins. This needs no
  schema change and no rewrite of existing rows.
- The periodic capacity recalculation uses the same rule as charge
  and release (offering ratio, else the cluster's) for running VMs and
  for capacity reserved by recently stopped VMs. Otherwise each check
  would reinstate a gap whenever a ratio changed after a VM started.
- The ratio lookup on charge and release runs inside the existing
  try block again, so a failure is logged as before instead of
  escaping the state transition.

Signed-off-by: Brad House <bhouse@nexthop.ai>
bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Nov 24, 2026
Carries the amended upstream version of "Allow a service offering to
set its own overcommit ratio" (apache#14112).

- Charge and release a VM by its offering's ratio against the cluster
  of the host it is on, instead of by the ratio recorded on the VM. A
  release then always matches the charge it undoes, after a
  migration, a retried start or a cluster ratio change.
- Live scale reconfigures the VM at the new offering's ratio and
  records that ratio on the VM. The capacity check asks for the change
  in the charge, which is scaled by each offering's ratio.
- Reject NaN and Infinity as offering ratios; treat them as unset if
  already stored.
- Only root admins may set the ratios when creating an offering (and,
  where cloning exists, change them on a clone). Ratio keys are stored
  under their canonical name.
- memoryReclaimDisabled is no longer shown to users.

Bundle-only, for offerings already in use:
- Offerings created by the previous code keep the ratio keys as typed.
  The ratios are read case-insensitively wherever the details are
  looked up in Java, so those offerings keep their ratio. Where two
  keys differ only in case, the canonical one wins. This needs no
  schema change and no rewrite of existing rows.
- The periodic capacity recalculation uses the same rule as charge
  and release (offering ratio, else the cluster's) for running VMs and
  for capacity reserved by recently stopped VMs. Otherwise each check
  would reinstate a gap whenever a ratio changed after a VM started.
- The ratio lookup on charge and release runs inside the existing
  try block again, so a failure is logged as before instead of
  escaping the state transition.

Signed-off-by: Brad House <bhouse@nexthop.ai>
A cluster's overcommit ratio applied to every VM on it, and the per-VM
detail recording it was force-synced to the cluster value on every
start, so nothing could be exempted. An offering may now set
cpuOvercommitRatio / memoryOvercommitRatio in its details.

Ratio resolution
- offering first, then cluster
- the VM records the ratio it runs at, which the hypervisor reads for
  min memory/speed and the recalculation uses for VMs that inherit it
- must be a finite number >= 1: rejected when the offering is created,
  ignored with a warning at start or placement for a detail written
  directly
- only root admins may set it (a domain admin's offering would otherwise
  oversubscribe shared hosts); a clone may carry the source's unchanged
- the key is stored under its canonical name whatever case it was given
  in, and may be given once
- a ratio above the cluster's is allowed and logged
- logic lives in VirtualMachineManagerOverCommit, called from start,
  migrate, unmanage and live scale

Capacity
- charge, refund and the periodic recalculation (running VMs and the
  reserved capacity of recently stopped ones) scale a VM whose offering
  sets a ratio by that ratio against the cluster of the host, so the
  books agree when ratios differ or change; the recalculation reads each
  offering once per host
- a VM whose offering sets no ratio is accounted as before
- the charge depends only on the offering and the host's cluster, so a
  release matches its charge after a migration or a start retried in
  another cluster
- live scale charges and sets min memory/speed at the new offering's
  ratio, and its host check asks for the change in that charge
- allocator and planner use the same scaling wherever room is checked
- no behaviour change while every VM shares its cluster's ratio

Memory on exempt VMs (KVM)
- an offering that explicitly asks for a memory ratio of 1 gets
  freePageReporting and autodeflate turned off, balloon kept for stats
- keyed on the offering asking, not on the resolved ratio being 1
- stored as a hidden VM detail, so users don't see it; it is set again
  at every start

UI
- two optional admin-only fields on the add/clone compute offering
  forms, blank = inherit the cluster
- serviceofferingdetails index is a running counter in add and clone, so
  a second detail no longer overwrites ImplicitDedicationMode
- clone lifts the ratios into the new fields instead of resubmitting
  them as external details
- the details tab shows both ratios
- updateServiceOffering takes only externaldetails, so the ratios are
  set at create or clone time

Signed-off-by: Brad House <bhouse@nexthop.ai>
@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Follow-up in 6d432e7: the periodic capacity recalculation now charges a VM whose offering sets a ratio at that ratio, for running VMs and for the capacity reserved by recently stopped ones, the same way charge and release do. A VM whose offering sets no ratio is accounted as before. The offering lookup on charge and release is also back inside the existing try blocks, so a failure there is logged as before.

@bhouse-nexthop
bhouse-nexthop force-pushed the per-offering-overprovisioning branch from 28ca1da to 6d432e7 Compare November 24, 2026 18:16
bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Nov 24, 2026
Aligns the periodic capacity recalculation (updateCapacityForHost)
with upstream apache#14112. A VM whose offering sets an
overcommit ratio is counted at that ratio, as allocate and release
charge it, both while running and while its capacity is reserved
after a stop. A VM whose offering sets none keeps the stock rule, the
ratio recorded on the VM when it started.

The previous commit fell back to the cluster's ratio for those VMs.
That changed the accounting of every VM without an offering ratio, and
after a cluster ratio raise it over-reported free memory up to twice
until the VMs restarted.

Signed-off-by: Brad House <bhouse@nexthop.ai>
bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Nov 24, 2026
Aligns the periodic capacity recalculation (updateCapacityForHost)
with upstream apache#14112. A VM whose offering sets an
overcommit ratio is counted at that ratio, as allocate and release
charge it, both while running and while its capacity is reserved
after a stop. A VM whose offering sets none keeps the stock rule, the
ratio recorded on the VM when it started.

The previous commit fell back to the cluster's ratio for those VMs.
That changed the accounting of every VM without an offering ratio, and
after a cluster ratio raise it over-reported free memory up to twice
until the VMs restarted.

Signed-off-by: Brad House <bhouse@nexthop.ai>

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.

3 participants