Properly calculate a cluster's free memory #373
Draft
+70
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cluster free memory in the vSphere CPI uses "effective_memory" [0] defined as follows [1]:
This sounds like it's "available free memory", but it's not. It's total effective memory that a cluster could give to VMs. This is the wrong metric to use for "free memory" as it does not vary based on the memory consumption for the cluster.
This commit changes the calculation to subtract from the effective memory the memory demand, "Sum of memory demand of all the powered-on VMs in the cluster" [2].
The new metric appears to more closely reflect vCenter's reporting of memory. For example, on https://vcenter-80.nono.io:
Note that although this new calculation of memory is more "truthful", measuring memory is nuanced: vSphere has 3 different metrics for memory use (memDemandMB, memEntitledMB, memReservationMB). Furthermore, on vCenter's cluster's summary page, the "free" memory (e.g. 184 GiB) doesn't dovetail with any of the available metrics, nor any combination thereof.
Drive-by:
VimSdk::Vim::ComputeResource::Summary
→VimSdk::Vim::ClusterComputeResource::Summary
in our tests because that was the object reflected in the vSphere MOB browser (we were instance-doubling the wrong object).[0]
bosh-vsphere-cpi-release/src/vsphere_cpi/lib/cloud/vsphere/resources/cluster.rb
Lines 209 to 216 in 3fc6d72
[1] https://vdc-download.vmware.com/vmwb-repository/dcr-public/90ec343b-df7c-493e-9979-36ea55765102/8753fd1e-fcab-4bd4-9cde-a364851f31a6/vim.cluster.UsageSummary.html
[2] https://vdc-download.vmware.com/vmwb-repository/dcr-public/3d076a12-29a2-4d17-9269-cb8150b5a37f/8b5969e2-1a66-4425-af17-feff6d6f705d/SDK/sms-sdk/docs/ReferenceGuide/vim.ComputeResource.Summary.html#effectiveMemory
Suggested release notes:
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Related PR and Issues
Fixes # (issue)
Impacted Areas in Application
List general components of the application that this PR will affect:
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: