Commit b5d77ca
committed
Properly calculate a cluster's free memory
cluster free memory in the vSphere CPI uses "effective_memory" [0]
defined as follows [1]:
Effective memory resources (in MB) available to run virtual
machines. This is the aggregated effective resource level from all
running hosts. Hosts that are in maintenance mode or are unresponsive
are not counted. Resources used by the VMware Service Console are not
included in the aggregate. This value represents the amount of resources
available for the root resource pool for running virtual machines.
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: the effective memory
490 GiB effective memory, old, wrong calculation
- 86 GiB demand memory
-------
404 GiB new, better calculation
420 GiB vCenter's reporting of "Available Reservation"
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:
- I changed `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] https://github.com/cloudfoundry/bosh-vsphere-cpi-release/blob/3fc6d72d7c69b40416e78663238a15d022a98415/src/vsphere_cpi/lib/cloud/vsphere/resources/cluster.rb#L209-L216
[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
[#183481442]1 parent 9f6166f commit b5d77ca
2 files changed
Lines changed: 12 additions & 5 deletions
File tree
- src/vsphere_cpi
- lib/cloud/vsphere/resources
- spec/unit/cloud/vsphere/resources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
| |||
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
| |||
291 | 295 | | |
292 | 296 | | |
293 | 297 | | |
294 | | - | |
| 298 | + | |
| 299 | + | |
295 | 300 | | |
296 | 301 | | |
297 | 302 | | |
298 | 303 | | |
299 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
300 | 307 | | |
301 | 308 | | |
302 | 309 | | |
| |||
0 commit comments