cloud_controller_ng icon indicating copy to clipboard operation
cloud_controller_ng copied to clipboard

v3/processes shows desired number of instances. No place for actual number of instances running.

Open mvadu opened this issue 4 years ago • 5 comments

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?

mvadu avatar Feb 17 '21 17:02 mvadu

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.

cf-gitbot avatar Feb 17 '21 17:02 cf-gitbot

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 avatar Feb 17 '21 18:02 Gerg

@Gerg I see what you mean.. My Ruby skills are non existent, but in nutshell

  1. Query all process for an app with GET /v3/apps/:guid/processes
  2. 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 }
  1. Count how many of them have state=RUNNING

mvadu avatar Feb 17 '21 19:02 mvadu

Yes, though if you want to exactly reproduce the v2 logic, you will need to count the instances with state = RUNNING OR STARTING.

Gerg avatar Feb 17 '21 20:02 Gerg

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

sethboyles avatar Feb 22 '21 20:02 sethboyles