Commit graph

169 commits

Author SHA1 Message Date
John O'Connor
8ed8c43970 (POOLER-160) Revise Metrics Classwork
Review changes suggested to revise the Metrics related files into a more
logical class structure.

Also fixup grammar typos in docs strings and any trailing metrics that
have been recently added to vmpooler.
2020-06-29 19:54:28 +01:00
John O'Connor
cb955a1bed (POOLER-177) Filter hostname from API Paths
Use the example provided in the Ruby Client to provide a customised
collector appropriate to log all calls to the API. The customised
filtering is used to replace individual node names and templates
for the /vm and request ID's for the /ondemand endpoints.

This module was failing our rubocop checks so have updated it since
it now forms part of vmpooler.

Separate trapping for litmus jobs is also included so that they don't
interfere with stats from the jenkins pipelines.
2020-06-29 19:53:59 +01:00
John O'Connor
b6dcd77228 (POOLER-170) Revise vmpooler usage stats
Break down the usage stats into smaller groups so as to manage the
number of stat lines collected for Prometheus.

This may need some further revision to filter out Litmus stats, or
otherwise collect litmus usage information.
2020-06-29 19:52:15 +01:00
John O'Connor
72564de4b4 (POOLER-160) Revise connection metrics
The redis pooler connection metric used "metric_prefix" which is
misleading, so split this into connpool_type and connpool_provider.
Also remove some earlier jruby compatibility code to reduce
rebase conflicts when this is rebased on top of Matt's changes.
2020-06-29 19:52:14 +01:00
John O'Connor
bbd76bde4c (POOLER-160) Add Prometheus to pooler startup
This is a re-architect of the vmpooler initialisation code to:
1. Allow an API service for both manager and the api
2. Add the Prometheus endpoints to the web service.
   Needed to change the way the Rack Service is started as instantiating
   using ".New" leads to a failure to initialise the http Stats
   collection.
3. Selectively load the pooler api and/or Prometheus endpoints.
4. Rework API Spec tests for revised API loading. Needed to tidy up the
   initialisation and perform a reset! after each test to avoid "leaks"
   and dependencies between the tests.
2020-06-29 19:52:14 +01:00
John O'Connor
ffab7def9e (POOLER-160) Add Prometheus Stats Feeds
Add a new Prometheus class as an additional stats feed along with the
existing feeds.

Move the metrics initialisation code into its own class and sub-class
the individual metrics implementations under this.
2020-06-26 21:37:22 +01:00
mattkirby
a2a3bb7dfd
Merge pull request #382 from puppetlabs/pooler-167
(POOLER-167) Allow for network configuration at vm clone time
2020-06-23 14:30:25 -07:00
Belen Bustamante
3dfd70fa0e Allow for network configuration at vm clone time 2020-06-12 11:56:41 -07:00
Samuel
4ecd5dea51
(POOLER-174) Reduce duplicate of on demand code introduced in POOLER-158 (#383)
* (POOLER-174) Reduce duplicate of on demand code introduced in POOLER-158
refactored every parsing of request of type 'pool_alias:pool:count' into a
utility class, that is used by pool_manager and the api v1 class
* add some metrics to the od request generation
* fix rubocop offenses, we are now friends
2020-06-11 12:39:34 -05:00
kirby@puppetlabs.com
811fd8b60f (POOLER-158) Add capability to provision VMs on demand
This change adds a capability to vmpooler to provision instances on
demand. Without this change vmpooler only supports retrieving machines
from pre-provisioned pools.

Additionally, this change refactors redis interactions to reduce round
trips to redis. Specifically, multi and pipelined redis commands are
added where possible to reduce the number of times we are calling redis.

To support the redis refactor the redis interaction has changed to
leveraging a connection pool. In addition to offering multiple
connections for pool manager to use, the redis interactions in pool
manager are now thread safe.

Ready TTL is now a global parameter that can be set as a default for all
pools. A default of 0 has been removed, because this is an unreasonable
default behavior, which would leave a provisioned instance in the pool
indefinitely.

Pool empty messages have been removed when the pool size is set to 0.
Without this change, when a pool was set to a size of 0 the API and pool
manager would both show that a pool is empty.
2020-06-03 14:00:04 -07:00
Samuel Beaulieu
6304743240 (POOLER-166) Check for stale dns records 2020-05-29 12:05:54 -05:00
Belen Bustamante
477f270b52 Enable support for multiple user objects 2020-05-28 10:42:47 -07:00
kirby@puppetlabs.com
68ecb7a3a4 (POOLER-165) Fix purge_unconfigured_folders
This commit fixes the purge_unconfigured_folders feature to ensure that it can successfully identify folders and instances that are no longer used. Without this change the feature does not work as advertised.
2020-04-07 09:39:59 -07:00
kirby@puppetlabs.com
283dea62a7 (POOLER-156) Detect redis connection failures
This commit adds detection for redis connection failures to pool_manager. When a connection fails the error will be raised to executeforcing the connection to be re-established. Without this change, when a redis connection fails, it generates a redis connection error, which is swallowed by a rescue for StandardError, preventing the manager application component from recovering in the case of a redis connection failure.
2020-03-17 11:17:52 -07:00
Brandon High
daa1a99073
Correct keyword arguments to traverse in create_folder
This commit fixes this call to `dc.vmFolder.traverse` to simply pass in
the arguements instead of assigning to variables that are discarded.
2020-03-05 17:10:22 -08:00
kirby@puppetlabs.com
8bb89b604d (POOLER-157) Add extra_config option to vmpooler
This commit adds the extra_config option to vmpooler to allow specifying additional configuration files to load from. Without this change vmpooler does not offer a mechanism to provide additional configuration files for the application.
2020-03-04 17:19:24 -08:00
Brandon High
82dae7d04c
Merge pull request #353 from mattkirby/vmpooler_flush
(POOLER-153) Add endpoint for resetting a pool
2020-02-14 09:53:47 -08:00
kirby@puppetlabs.com
52b60b074c (POOLER-153) Add endpoint for resetting a pool
This commit adds a capability to vmpooler to reset a pool, deleting its ready and pending instances and replacing them with fresh ones. Without this change vmpooler does not offer a mechanism to reset a pool without also changing its template.
2020-02-13 11:59:44 -08:00
Sean Millichamp
f6fdfe42d7 Support nested host folders in find_cluster()
Search the root and any subfolders for cluster or host resources.
2019-11-26 13:48:53 -05:00
Brandon High
019ed021b0
(QENG-7530) Add check for unique hostnames
Prior to this commit the pooler had no awareness of the complete set of
hostnames that are currently in use. This meant that it was possible to
allocate the same hostname twice, which would result in the original
host with that hostname becoming unreachable.

This commit adds a check for the existence of the
`vmpooler__vm__<hostname>` key before attempting to  clone the vm.
This should prevent duplicate hostnames.

If the hostname is already taken, `_clone_vm` will retry with a new
random hostname multiple times before raising an exception.
2019-11-04 15:53:05 -08:00
Brandon High
625472df35
(QENG-7530) Fix hostname_shorten regex
Prior to this commit the hostname_shorten regex wouldn't match the
updated human readable hostnames because they contain dashes.
This commit updates the regex to capture dashes in the hostname, and
adds a few specs to verify that behavior.
2019-11-01 10:30:56 -07:00
kirby@puppetlabs.com
267772d8eb (POOLER-147) Fix create_linked_clone pool option
This commit updates the create_linked_clone pool option to correctly detect when linked clones have been set at a pool level. Without this change a pool setting create_linked_clone to false is not interpreted correctly, and a linked clone is created if possible.
2019-08-22 14:32:06 -07:00
kirby@puppetlabs.com
9c5a0d114b (POOLER-142) Add running host to vm API data
This change adds the running host for a VM to the API data available via /vm/hostname. Without this change the running host would be logged to vmpooler log, but not available any other way. Additionally, the data will specify if a machine has been migrated. Without this change parent host data for a vmpooler machine is not available via the vmpooler API.
2019-08-21 12:43:06 -07:00
kirby@puppetlabs.com
09a382a10f Make it possible to disable linked clones
This commit adds a new configuration parameter to allow setting whether to create linked clones on a global, or per pool basis. Without this change vmpooler would always attempt to create linked clones. The default behavior of creating linked clones is preserved.
2019-08-06 14:29:31 -07:00
Spencer McElmurry
98a547b807 (POOLER-143) Add clone_target config change to API
This allows the user to change the cluster in which the targeted pool
will clone to. Upon configuration change, the thread will wake up and
execute the change within 1 second.
2019-07-29 08:53:27 -07:00
Samuel Beaulieu
8eb15f8d10 (maint) Optimize the status api using redis pipeline
Before this change looping over many pools would query the redis backend
for each pool, leading in slow response from the backend for configurations
with many pools (60+)
Changed the requests to use redis pipelines https://redis.io/topics/pipelining
This is supported since the beginning, so will not force any redis update for
users. The pipeline method runs the queries in batches and we need to loop
over the result and reduces the number of requests to redis by N=number of
pools in the configuration.
2019-04-18 13:24:40 -05:00
kirby@puppetlabs.com
d94b14a4d8 (POOLER-137) Support integer environment variables
This commit updates vmpooler to set configuration values received via environment variables to integer values when an integer value is expected. Without this change vmpooler does not support setting integer values via environment variables. Additionally, testing is added for configuring vmpooler via environment variables.

To support this testing the gem climate_control is added, which allows
for testing environment variables without those set variables leaking to
other tests.
2019-01-22 15:02:07 -08:00
kirby@puppetlabs.com
2de4a6db0b Ensure nodes are consistent for usage stats
This commit updates vm usage stats collection to replace all instances of '.' characters within node strings. Without this change the node string containing a '.' character causes the metric to be interpreted as containing another node.
2018-12-19 12:45:50 -08:00
kirby@puppetlabs.com
60b8715a80 Update providers_spec to match array contents
This commit updates providers_spec so the test ensures array content of the providers match. Without this change the provider_spec test will fail when comparing providers if the order is not exactly the same in each array.
2018-12-07 17:08:08 -08:00
kirby@puppetlabs.com
9a57c6d1b5 (POOLER-134) Ship VM usage stats
This commit updates vmpooler to ship VM usage stats when a VM is destroyed. The stats are gathered for jobs based on user and pool name. If a jenkins build URL is present then this is broken down by user, instance, value stream, branch and project. Additionally, if present then the RMM_COMPONENT_TO_TEST_NAME will be listed after project. Without this change we do not collect stats on per VM usage and its correlation to users and pools.
2018-12-07 11:59:27 -08:00
kirby@puppetlabs.com
3c856d7ae9 (POOLER-133) Identify when a ready VM has failed
This commit fixes checking of a VM that has already been identified as ready. Without this change a ready VM that has failed will be identified as having failed, but will not successfully be removed from the ready queue. Additionally, the default vm_checktime value has been reduced from 15 to 1 to ensure that ready VMs are checked within one minute of the time they have reached the ready state by default.

Lastly, the docker-compose files are updated to specify that the redis
instance used is a local redis instance.
2018-12-03 12:21:08 -08:00
kirby@puppetlabs.com
830acd705d Remove debug statements. Return when get_vm returns nil 2018-09-12 12:28:12 -07:00
mchllweeks
0e86937245
Merge pull request #297 from mattkirby/pooler_130
(POOLER-130) Improve delta disk creation handling
2018-08-30 17:22:35 -07:00
kirby@puppetlabs.com
3fd0c6f475 (POOLER-130) Improve delta disk creation handling
This commit updates delta disk creation to reduce the likelihood of this being run more than once for any given template. Without this change an error can be generated with vsphere 6.5 or later when a template is updated, and then the update is reverted. The error prevents the image from being used because the template is never marked as prepared. To address this any failure is now logged, and the template is marked as prepared regardless of whether this was successful, or not, which allows the image to be used despite the error. This failure mode is more graceful and allows the pool to continue to function.
2018-08-30 15:50:07 -07:00
Samuel Beaulieu
3aac95d5b9 (POOLER-114) Refactor check_pool in pool_manager
This commit refactorss the check_pool method in pool_manager.
Specifically, each commented section describing a stage of check_pool is
broken out into a separate method and check_pool is simplified by
calling these methods. Without this change it is difficult to follow the
intent for or make changes to check_pool.

Additionally, a docker-compose file is added to make it simple to launch
an all-in-one vmpooler instance along with a separate redis server with
docker.
2018-08-23 14:04:52 -07:00
Corey Osman
2daa5244b8 Adds a new mechanism to load providers from any gem or file path. (#263)
* Adds ability to load only providers used in config file
2018-07-24 16:35:18 -07:00
kirby@puppetlabs.com
490e5c1938 (POOLER-128) Remove references to VM mutex when destroying
This commit updates destroy_vm to remove references to its mutex tracking object when destroyed. Without this change a VM that is destroyed will leave its mutex tracking object forever causing the pool manager memory footprint to increase.
2018-07-23 16:53:53 -07:00
Steve Axthelm
c3d90dbfa6 (maint) change domain to example.com
Prior to this commit the docs and examples used 'company.com'
(a real domain). This commit changes those occurrences to
'example.com', which is a IANA-managed reserved domain.
2018-07-19 15:23:30 -07:00
Kevin Imber
099b53f348
Merge pull request #274 from mattkirby/cleanup_unused_folders_and_vms
(POOLER-66) Purge vms and folders no longer configured
2018-07-19 13:19:13 -07:00
Spencer McElmurry
5ca85beb18
Merge pull request #283 from mattkirby/remove_find_pool
(MAINT) Remove find_pool and update pending tests
2018-07-16 10:25:16 -07:00
kirby@puppetlabs.com
ff1d288b53 (MAINT) Remove find_pool and update pending tests
This commit removes find_pool, which is no longer used. Additionally, tests which are listed as pending and have been resolved are removed from pending tests. Lastly, a folder check that doesn't make sense given the change in method for finding objects is removed.
2018-07-13 12:42:09 -07:00
kirby@puppetlabs.com
a34c8dd11b (POOLER-66) Purge vms and folders no longer configured
This commit enables optional purging for vms and folders when they are
not configured in the vmpooler provided configuration. Base folders are
determined from folders specified in the pool configuration. Then,
anything not configured in that folder for that provider and is not a
whitelisted folder title will be destroyed. Without this change vmpooler
will leave unconfigured vms and folders behind and any vms will be left
running forever without manual intervention. Additionally, any
associated redis data will never be expired.
2018-07-13 12:09:28 -07:00
mattkirby
070199e877 Eliminate duplicate VM object lookups where possible (#269)
* Minimize duplicate checking of VMs

This commit updates check_pool pending, running and ready methods to greatly reduce instances in which the VM object is retrieved. Without this change get_vm is run for each of these check_pool steps even though the VM is already validated as being in inventory being running the check. This is left for checking running VMs when the VM is no longer ready. Without this change there is an unnecessarily large volume of VM object checks.

* Make hostname mismatch checking optional

This commit makes hostname mismatch checking optional on a pool and global config level. The default behavior of checking this is preserved. When disabled _check_ready_vm will not run get_vm, which allows for ready VMs to be checked without retrieving an object from vsphere and waiting for a free provider connection. Without this change it is not possible to disable VM object retrieval in _check_vm_ready.

* Check if a hostname return is empty string

This commit checks whether a hostname returned is an empty string.
Without this change a VM that returns a hostname with a empty string
will report as having a hostname mismatch, which may happen before all
VM data is updated.

* Only check hostname for mismatch after time since ready has past

Configure hostname checking so it is not checked until a VM has been
ready for greater than one minute. Without this change hostname checking
will often fail because the configured value has not propogated to the
VM on some platforms before this check is run.
2018-07-13 12:06:44 -05:00
Spencer McElmurry
a865e6bd2f (POOLER-34) Ship clone request to ready time to metrics (#277)
* (POOLER-34) Ship clone request to ready time to metrics

Before, we were already capturing this metric but we failed to ship
it anywhere. This ships the appropriate metric as `time_to_ready_state`
Dashboards can be found in grafana.

* Add spec test to ensure metric is being shipped properly on
move_pending_vm_to_ready call.
2018-07-09 16:22:49 -07:00
kirby@puppetlabs.com
9ddd3c21b7 (MAINT) Fix test reference to find_vm
This commit updates a test reference to find_vm. This method has been renamed find_vm_folder, so this commit updates usage to reflect the new title and reduced arguments required. Without this change tests fail on master.
2018-07-09 14:57:07 -07:00
mchllweeks
6f4f3cc4e7
Merge pull request #273 from mattkirby/pooler_124
(POOLER-124) Fix evaluation of max_tries
2018-07-09 12:50:34 -07:00
mchllweeks
afc5a33d8f
Merge pull request #272 from mattkirby/pooler_40
(POOLER-40) Do not return folders with get_pool_vms
2018-07-09 12:50:00 -07:00
mchllweeks
2f98b1bd7a
Merge pull request #271 from mattkirby/less_delta_disks
Ensure template deltas are created once
2018-07-09 12:49:08 -07:00
mchllweeks
69f8b21ca8
Merge pull request #270 from mattkirby/no_duplicate_vms_in_pool
Do not run duplicate instances of inventory check for a pool
2018-07-09 12:48:41 -07:00
mchllweeks
a72012b754
Merge pull request #268 from mattkirby/reduce_object_lookups
Reduce object lookups for finding folders
2018-07-09 12:46:17 -07:00