[QENG-4181] Add per-pool stats to /status API

Prior to this the only per-pool statistics that could be extracted from the API
were a list of empty pools in the "status" section of the returned results of
the `/status` endpoint.

This adds a new "pools" section to the '/status' results which lists, for each
pool, the following results:

 - The number of ready vms in the pool
 - The number of running vms in the pool
 - The number of pending vms in the pool
 - The maximum size of the pool (as specified in the vmpooler configuration)

Example:

```
{
  "boot": {
  "duration": {
    "average": 163.6,
    "min": 65.49,
    "max": 830.07,
    "total": 247744.71000000002
  },
  "count": {
    "total": 1514
  }
  # ...
  "pools": {
    "pool1": {
      "ready":   5,
      "running": 2,
      "pending": 1,
      "max":     15
    },
    "pool2": {
      "ready":   0,
      "running": 10,
      "pending": 0,
      "max:      10
    }
  }
}
```

This includes spec coverage for this change (we could use more specs on `/status` in general); as well as a couple of general spec improvements.
This commit is contained in:
Rick Bradley 2016-09-09 17:00:47 -05:00
parent 1bf0af2ba5
commit 30dc060731
3 changed files with 134 additions and 3 deletions

View file

@ -35,8 +35,7 @@ end
def create_ready_vm(template, name, token = nil)
create_vm(name, token)
redis.sadd("vmpooler__ready__#{template}", name)
# REMIND: should be __vm__?
redis.hset("vmpooler_vm_#{name}", "template", template)
redis.hset("vmpooler__vm__#{name}", "template", template)
end
def create_running_vm(template, name, token = nil)
@ -45,6 +44,12 @@ def create_running_vm(template, name, token = nil)
redis.hset("vmpooler__vm__#{name}", "template", template)
end
def create_pending_vm(template, name, token = nil)
create_vm(name, token)
redis.sadd("vmpooler__pending__#{template}", name)
redis.hset("vmpooler__vm__#{name}", "template", template)
end
def create_vm(name, token = nil)
redis.hset("vmpooler__vm__#{name}", 'checkout', Time.now)
if token