Commit graph

909 commits

Author SHA1 Message Date
mattkirby
7e5ef2f4e5
Merge pull request #264 from logicminds/gemspec
Adds a gemspec file
2018-07-13 09:23:11 -07:00
Spencer McElmurry
12bba418d1 (POOLER-81) Add time remaining information (#280)
* (POOLER-81) Add time_remaining information

Before, the only time calculation displayed for a given VM was the
lifetime parameter. Added the remaining parameter which will
display time until the VM is destroyed as a float.

Additionally, start_time and end_time were added to api to return
as UTC based times (e.g. 2018-07-10 11:01:03 -0700).

* Remove abs eval from GET, rework spec tests to check each field.
This allows us to account for "flakiness" of the remaining return.

* Change datetime to RFC3339 for start_time and end_time
2018-07-12 09:40:22 -07:00
Spencer McElmurry
84065dd059 Revert "(POOLER-81) Add time_remaining information" (#279)
* Revert "(POOLER-34) Ship clone request to ready time to metrics (#277)"

This reverts commit a865e6bd2f.

* Revert "(POOLER-81) Add time_remaining information (#276)"

This reverts commit 1910cffaf7.
2018-07-10 09:00:12 -07: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
Spencer McElmurry
1910cffaf7 (POOLER-81) Add time_remaining information (#276)
* (POOLER-81) Add time_remaining information

Before, the only time calculation displayed for a given VM was the
lifetime parameter. Added the time_remaining parameter which will
display time until the VM is destroyed in hours, minutes, seconds.

Additionally, updated the running parameter to display in a similar
fashion as time_remaining.

* Add spec testing for testing time_remaining stat
2018-07-09 16:22:05 -07:00
Spencer McElmurry
f27e2c1301
Merge pull request #278 from mattkirby/fix_folder_test
(MAINT) Fix test reference to find_vm
2018-07-09 15:04:24 -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
Samuel
596af14918
Merge pull request #275 from mattkirby/jruby_92
Add jruby 9.2 to travis testing
2018-07-06 17:45:08 -05:00
kirby@puppetlabs.com
bc4bf32638 Add jruby 9.2 to travis testing
This commit adds jruby 9.2 to travis testing. Without this change vmpooler is not tested against jruby 9.2.
2018-07-05 17:17:24 -07:00
kirby@puppetlabs.com
faaec4f9bc (POOLER-124) Fix evaluation of max_tries
This commit updates usage of max_tries to ensure that the increment of the try value happens after evaluation of whether max_tries has been exceeded. Without this change max_tries doesn't work as advertised. Additionally, checking looks to see if try is greater than or equal to so the try count exceeding max_tries would also be detected.
2018-07-03 11:24:05 -07:00
kirby@puppetlabs.com
bd0ae2e192 (POOLER-40) Do not return folders with get_pool_vms
This commit updates get_pool_vms to only return if the object is a VirtualMachine. Without this change a folder wtihin a VM target folder can be discovered and destroyed as though it were a VM.
2018-07-03 11:09:07 -07:00
kirby@puppetlabs.com
170d2090f8 Add some documentation to get_vm_hash 2018-07-03 09:12:05 -07:00
kirby@puppetlabs.com
70156ba7f7 Do not prepare template when config_template is set 2018-07-02 14:12:17 -07:00
kirby@puppetlabs.com
1b17cceb01 Ensure template deltas are created once
This commit updates how template delta disk creation is evaluated. Without this change template deltas are created for every template on each applicatoin startup. This change updates this behavior to instead run template delta disk creation only once per template configured for a pool. Without this change it is possible to get a template to a state where the XML depth is too great to be read with default settings and the template requires a new clone to resolve.
2018-07-02 09:53:41 -07:00
mchllweeks
0ce66eb763
Merge pull request #266 from mattkirby/pooler_31
(POOLER-31) Expire redis vm key when clone fails
2018-06-29 16:43:04 -07:00
kirby@puppetlabs.com
df89617fdc Do not run duplicate instances of inventory check for a pool
This commit updates check_pool inventory check to prevent multiple instances from running at once. Without this change the inventory check may run in multiple threads simultaneously.
2018-06-28 20:32:44 -07:00
kirby@puppetlabs.com
a6c2ef7bf3 Rename find_folder to find_vm_folder
This commit renames find_folder to find_vm_folder to clarify its intent to retrieve folders from the VM hierarchy. Without this change find_folder implies it may find folders that are not within the VM hierarchy.
2018-06-28 15:26:09 -07:00
kirby@puppetlabs.com
5c857f50f1 Replace find_folder with searchindex inventorypath
This commit replaces find_folder to use information already known about folders to determine their location and quickly fail when it does not exist without traversing the hierarchy. Without this change find_folder is very inneficient and can take a long time to return depending on how deep in the folder tree the folder exists.
2018-06-28 15:25:51 -07:00
kirby@puppetlabs.com
8840ef4a5c Reduce object lookups for get_vm
This commit reduces object lookups used for get_vm. Without this change get_vm looks up the VM folder, which is already used and known to find the vm with find_vm.
2018-06-28 15:25:25 -07:00
mchllweeks
8be578493a
Merge pull request #267 from mattkirby/multiple_ldap_search
(POOLER-113) Add support for multiple LDAP search bases
2018-06-27 15:26:49 -07:00
kirby@puppetlabs.com
4fa54c8008 Move net/ldap require into vmpooler.rb
This commit moves net/ldap require from authenticate_ldap in api/helpers to vmpooler.rb. Without this change net/ldap and rubygems are required again every time authenticate_ldap is run.
2018-06-27 15:21:15 -07:00
kirby@puppetlabs.com
cbd4567454 Provide valid configuration for auth
This commit removes a additional authenticate method that is defined in the token_spec tests. Instead, authenticate is used from api/helpers. To support this change the config provided is updated to specify a dummy provider. Without this change authenticate cannot be tested along with token_spec because token_spec redefines authenticate.
2018-06-27 14:41:27 -07:00
kirby@puppetlabs.com
9fa27af8e5 (POOLER-113) Add support for multiple LDAP search bases
This commit updates vmpooler to support setting an array of search bases
in addition to a single base provided as a string. Without this change
it is not possible to specify multiple search bases to use with the LDAP
authentication provider. Additionally, test coverage is added to
the authentication helper method.
2018-06-25 21:37:22 -07:00
kirby@puppetlabs.com
3a6e2a5cac (POOLER-31) Expire redis vm key when clone fails
This commit updates pool_manager to expire a redis VM key when a clone fails. Without this change VMs that fail to clone have their metadata left forever.
2018-06-20 17:27:31 -07:00
mchllweeks
de813943e9
Merge pull request #265 from mattkirby/destroy_once
(POOLER-112) Ensure a VM is only destroyed once
2018-06-20 13:51:43 -07:00
kirby@puppetlabs.com
3a0f0880e7 (POOLER-112) Ensure a VM is only destroyed once
This commit implements a vm_mutex hash to allow synchronizing VM operations that should only happen once across threads. Without this change pool_manager will try to evaluate or destroy a VM multiple times, which results in an error being thrown by one of the destroy attempts as only one can succeed and a duplication of resources unnecessarily when there are no errors.
2018-06-20 13:40:49 -07:00
Samuel
89e1f17738
Merge pull request #261 from mattkirby/fix_ignore_cert
Change default vsphere connection behavior
2018-06-20 15:27:40 -05:00
Samuel
d736b1e978
Merge pull request #260 from mattkirby/fix_check_disk
Remove propertyCollector from add_disk
2018-06-20 15:25:38 -05:00
Samuel
63fb23154c
Merge pull request #256 from mattkirby/config_changes_squash
(POOLER-107) Add configuration API endpoint
2018-06-20 15:23:44 -05:00
kirby@puppetlabs.com
9bb4df7d8e (POOLER-107) Add configuration API endpoint
This commit adds a configuration endpoint to the vmpooler API. Pool
size, and pool template, can be adjusted for pools that are configured
at vmpooler application start time. Pool template changes trigger a pool
refresh, and the new template has delta disks created automatically by
vmpooler.

Additionally, the capability to create template delta disks is added to
the vsphere provider, and this is implemented to ensure that templates
have delta disks created at application start time.

The mechanism used to find template VM objects is simplified to make the flow of logic easier to understand. As an additional benefit, performance of this lookup is improved by using FindByInventoryPath.

A table of contents is added to API.md to ease navigation. Without this change API.md has no table of contents and is difficult to navigate.

Add mutex object for managing pool configuration updates

This commit adds a mutex object for ensuring that pool configuration changes are synchronized across multiple running threads, removing the possibility of two threads attempting to update something at once, without relying on redis data. Without this change this is managed crudely by specifying in redis that a configuration update is taking place. This redis data is left so the REPOPULATE section of _check_pool can still identify when a configuration change is in progress, and prevent a pool from repopulating at that time.

Add wake up event for pool template changes

This commit adds a wake up event to detect pool template changes.
Additionally, GET /config has a template_ready section added to the
output for each pool, which makes clear when a pool is ready to populate
itself.
2018-06-15 10:15:47 -07:00
mattkirby
e781ed258b Update ruby versions for travis (#259)
This commit updates ruby versions specified for use when testing in
travis.yml. Specifically, ruby 2.4.x and 2.5.x are added, while 2.2 is
updated to 2.2.10, and 2.3 is updated to 2.3.7. Additionally, jruby
testing is updated to use 9.1.17.0. Without this change we do not test
ruby 2.4.x or 2.5.x with vmpooler.
2018-06-14 15:21:35 -05:00
Spencer McElmurry
c77e0c4c65
Merge pull request #257 from mattkirby/redis_port_password
Add support for setting redis port and password
2018-06-13 09:08:04 -07:00
Corey Osman
148f92591e Adds a gemspec file 2018-06-12 12:01:26 -07:00
kirby@puppetlabs.com
af8b73b6c9 Change default vsphere connection behavior
This commit changes the vsphere connection behavior to set insecure false. Without this change insecure is always set to true when making a connection regardless of the setting provided with the provider configuration.
2018-06-08 12:40:03 -07:00
FrozenFOXX
65fb4c9919 Update to generic launcher
I realized the launcher itself handles looking up the Ruby interpreter with /usr/bin/env ruby. Manually specifying an interpreter is going to try to circumvent that and isn't nearly as portable as an example service. By moving this sample script back to the generic launcher directly a user can choose to handle how /usr/bin/env looks up Ruby, whether it's with a jruby installation, rbenv, or however the user wishes.
2018-06-08 12:10:44 -07:00
kirby@puppetlabs.com
d1ae85c8af Remove propertyCollector from add_disk
This commit updates add_disk to remove propertyCollector, which was used
to back the find_vmdks method to locate the disk file on datastore and
then use its length to name the new disk. Instead, the number of disks
on the VM is used to ensure a unique disk resource title. Without this
change add_disk can take 10-50x longer due to the propertyCollector
method. Additionally, without this change propertyCollector is used in a
non threadsafe manner, which may cause stability issues for vsphere
provider backends.
2018-06-04 11:51:55 -07:00
kirby@puppetlabs.com
9b8b35395d Add dockerfile without redis
This commit adds a dockerfile to install vmpooler without a local redis installation. Without this change the dockerfile provided assumes a local redis instance will be running. The dockerfile with redis is retained as 'Dockerfile-aio'. Additionally, the directory '/var/log/vmpooler' is no longer created since vmpooler uses '/var/log/vmpooler.log'.
2018-05-30 12:19:05 -07:00
FrozenFOXX
67d5ef73c2 Adjusted with jruby
Since the new recommended way to run is with JRuby I've adjusted the startup service to reflect that.
2018-05-30 12:18:49 -07:00
FrozenFOXX
f69e9398c1 Create vmpooler.service 2018-05-30 12:18:49 -07:00
kirby@puppetlabs.com
a9ca914832 Add support for setting redis port and password
This commit adds options for setting redis port and password. Without this change it is not possible to specify the redis port or password.
2018-05-30 12:18:05 -07:00
Spencer McElmurry
3e8f5eb031
Merge pull request #251 from mattkirby/fix_heavy
(POOLER-68) Replace find_vm search mechanism
2018-05-29 11:31:09 -07:00
kirby@puppetlabs.com
4700ad2bb8 (POOLER-68) Replace find_vm search mechanism
This commit replaces find_vm and find_vm_heavy with a more performant and reliable mechanism of identifying VM objects. Specifically, FindByInventoryPath is able to leverage known data about a VM, its folder path and datacenter, and use that to identify whether that VM exists by its location. Without this change find_vm_heavy is called each time a VM cannot be found, which is frequent, and in doing so uses PropertyCollector in a manner that is not thread-safe. Additionally, this PropertyCollector usage does not clean up its traces, which can cause vCenter appliance instability issues on VCSA 6.x.
2018-05-14 09:12:20 -07:00
kirby@puppetlabs.com
00970ffc9e (POOLER-103) Fix configuration file loading
This commit updates the method used to load a configuration file to use
YAML.load_file, which is how it was configured previously. The
capability to specify an alternate configuration file via the
VMPOOLER_CONFIG_FILE is retained, and now works as expected.
2018-05-11 17:49:14 -07:00
kirby@puppetlabs.com
356c541fdc (POOLER-101) Update nokogiri and net-ldap
This commit updates nokogiri and net-ldap to versions that have fixed known vulnerabilities. Without this change vmpooler requires versions of each gem that contain known vulnerabilities.
2018-05-11 17:48:53 -07:00
Samuel Beaulieu
10245321bf (maint) Add the last boot time for each pool
This commit add a redis hash where there is one key per pool, and the
stored value is the last time a VM was booted e.g. the last time
a VM went from 'pending' to 'ready'. This is also displayed in the
API as lastBoot:'2018-03-23 17:43:39 +0000'. The data can then be
used by any external system, in this case our alarming system.
2018-03-28 11:11:49 -07:00