Repository navigation
Allow a service offering to set its own overcommit ratio - #14112
bhouse-nexthop wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
35b3a98 to
51c29f3
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
51c29f3 to
a0f4f34
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
a0f4f34 to
132c151
Compare
132c151 to
a6d3b42
Compare
|
@blueorangutan package |
|
@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. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19740 |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
a6d3b42 to
9a3f9b5
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
9a3f9b5 to
ed74e43
Compare
DaanHoogland
left a comment
There was a problem hiding this comment.
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?
Test report: per-offering overcommit ratiosEnvironment
1. Capacity charged at start
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
3. VM details
4. libvirt
5. Validation
6. Placement uses the same units
7. A cluster with no overcommit is unaffected
8. The offering form
Result: pass.
Not covered
|
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
@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. Functional consequences
The lab test of all this is in the earlier report. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
27b21a1 to
8b6b24f
Compare
c1231ef to
28ca1da
Compare
|
Rebased onto current main and squashed into one commit (28ca1da). The only conflict was in Another review pass found a few holes, now fixed in the same commit:
Tests: Known limits:
@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. |
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>
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>
|
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. |
28ca1da to
6d432e7
Compare
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>
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>
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
cpuOvercommitRatioormemoryOvercommitRatioin its detailsbefore, 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.
14Values 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
1as0.1- which would have charged the VMten 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 forImplicitDedicationModein the add and clone views,so any second detail written at index 0 silently replaced it. Both now use a running index.
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.
updateServiceOfferingaccepts onlyexternaldetails, so the ratios are set at create or clonetime, 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
updateCapacityForHostalready scaled eachVM 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
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
CapacityManagerScaleToClusterUnitsTest- 7 cases on scaling a request into capacity units: a VMinheriting 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 getsrecorded 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: nofreePageReporting, noautodeflate, balloon device and statistics still present.Full
mvn testonengine/components-api,engine/orchestration,serverand the KVM plugin withcheckstyle and license checks enabled: 0 failures.
UI:
vue-cli-service lintover 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:
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.
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 CPUcombinations - 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.