(DIO-2675) Undo pool size template overrides

This implements a delete method for pooltemplate and poolsize. The API
removes the override from Redis and then adds an entry in Redis that
causes the pool manager to wake up and process the removal of the
override.

To facilitate this, a new variable has been created in lib/vmpooler.rb
to hold a copy of the original / pre-override config. This supplemental
copy of the pools is then indexed for use as a reference.

When pool manager wakes up to process an override removal, it looks up
the pre-override value from the config via the new variables mentioned
above.

Just as with entering overrides, no restart is needed. Template and pool
size changes are logged so that anyone watching or reviewing the logs
can see what happened when. The new API endpoints also return values for
both the pre-revert and post-revert value.
This commit is contained in:
Gene Liverman 2021-10-14 15:08:55 -04:00
parent 6db71d8589
commit a0caa41a54
No known key found for this signature in database
GPG key ID: 3AF83985B6C857C6
7 changed files with 409 additions and 6 deletions

View file

@ -743,6 +743,28 @@ $ curl -X POST -H "Content-Type: application/json" -d '{"debian-7-i386":"2","deb
}
```
##### DELETE /config/poolsize/<pool>
Delete an overridden pool size. This results in the values from VMPooler's config being used.
Return codes:
* 200 - when nothing was changed but no error occurred
* 201 - size reset successful
* 401 - when not authorized
* 404 - pool does not exist
* 405 - The endpoint is disabled because experimental features are disabled
```
$ curl -X DELETE -u jdoe --url vmpooler.example.com/api/v1/poolsize/almalinux-8-x86_64
```
```json
{
"ok": true,
"pool_size_before_overrides": 2,
"pool_size_before_reset": 4
}
```
##### POST /config/pooltemplate
Change the template configured for a pool, and replenish the pool with instances built from the new template.
@ -775,6 +797,28 @@ $ curl -X POST -H "Content-Type: application/json" -d '{"debian-7-i386":"templat
}
```
##### DELETE /config/pooltemplate/<pool>
Delete an overridden pool template. This results in the values from VMPooler's config being used.
Return codes:
* 200 - when nothing was changed but no error occurred
* 201 - template reset successful
* 401 - when not authorized
* 404 - pool does not exist
* 405 - The endpoint is disabled because experimental features are disabled
```
$ curl -X DELETE -u jdoe --url vmpooler.example.com/api/v1/pooltemplate/almalinux-8-x86_64
```
```json
{
"ok": true,
"template_before_overrides": "templates/almalinux-8-x86_64-0.0.2",
"template_before_reset": "templates/almalinux-8-x86_64-0.0.3-beta"
}
```
##### POST /poolreset
Clear all pending and ready instances in a pool, and deploy replacements