cloud_controller_ng
cloud_controller_ng copied to clipboard
v3/processes shows desired number of instances. No place for actual number of instances running.
instances in the-process-object mentioned as The number of instances to run. That indicates a desired state. I don't see any place to get the actual instances running (more like running_instaces in old space_summary response.
Can this be considered as an extension to work being done for #2098?
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/176983928
The labels on this github issue will be updated when the story is started.
You can get this information by summing the instances with your desired state(s) from the stats endpoint.
For example here is how the cf CLI does it: https://github.com/cloudfoundry/cli/blob/ce247052b220d664b63ba85e2cf1b7f612c629bc/actor/v7action/process_summary.go#L24-L36
It's worth noting that in v2, the running_instances field included both running and starting instances, which might not be desired: https://github.com/cloudfoundry/cloud_controller_ng/blob/60a2a9e30dc6f743fb107592e898e83d6f0ee0c1/app/controllers/runtime/space_summaries_controller.rb#L39-L47
@Gerg I see what you mean.. My Ruby skills are non existent, but in nutshell
- Query all process for an app with
GET /v3/apps/:guid/processes - Query the stats for each processes with
instances> 0. which is processes with at least one desired instances.
foreach(type in process.where(p=>p.instances>0).select(p=>p.type))
{ GET /v3/apps/:guid/processes/:type/stats }
- Count how many of them have
state=RUNNING
Yes, though if you want to exactly reproduce the v2 logic, you will need to count the instances with state = RUNNING OR STARTING.
Perhaps the documentation could be improved by explaining the difference between v3/processes and v3/processes/.../stats (i.e. desired vs actual state)
Right now the docs don't really explain anything: http://v3-apidocs.cloudfoundry.org/version/release-candidate/#get-stats-for-a-process