Commit graph

123 commits

Author SHA1 Message Date
kirby@puppetlabs.com
e92ae559f5 Remove references to redis in migrate_vm 2018-01-10 12:02:58 -08:00
kirby@puppetlabs.com
cd979fc24d Move migrate_vm logic to vsphere provider
This commit moves the migrate_vm logic to the vsphere provider. Without
this change migrate_vm has lots of vsphere specific logic in
pool_manager migrate_vm method.
2018-01-10 12:02:58 -08:00
kirby@puppetlabs.com
23242a7b1c Update pool_manager and vsphere tests to support changes in host selection 2018-01-10 12:02:58 -08:00
Samuel
0b5abd9bd3 Fix no implicit conversion to rational from nil (#239)
* Fix no implicit conversion to rational from nil
Before this change if the boottime was nil, the check_ready
loop would exit on Time.now - host['boottime'] with a TypeError
in jruby. The boottime is nil when the power is Off so moving that check
earlier should catch that bug.

* set test data properly
2017-10-17 17:51:02 -05:00
Glenn Sarti
f209c2b830 (GH-226) Respond quickly to VMs being consumed
Previously in commit 9b0e55f959 the looping period was changed from a static
number to a dynamic one depending on load, however this meant that the operation
to refill a pool was slowed down somewhat.  While not a problem under normal
loads, when a pool was quickly consumed, the pool manager may not respond
quickly enough to refill the pool.  This commit:

- Changes the sleep method, to us a helper sleep method that will wakeup
  periodically and evaluate other wakeup events.  This could be used later to
  exist sleep loops when pooler is shutting down to stop blocking threads
- By default the wakeup_period is set to the minimum pool check loop time, thus
  emulating the behaviour prior to commit 9b0e55f959
- Adds tests for the behaviour
2017-09-05 21:41:32 -07:00
mattkirby
d789dfdfc8 Merge pull request #229 from glennsarti/fix-phantom-vms
(maint) Remove phantom VMs that are in Redis but don't exist in provider
2017-08-01 10:38:25 -07:00
Glenn Sarti
e55a8825af (maint) Remove phatom VMs and ensure inventory is successful
Previously, if inventory failed for some reason, it would return an incomplete
set of VMs which could then cause the pool to perform off behaviours such as
fill the pool high than it should, or remove VMs which exist.  Also, if the
redis cache of VMs in a pool had a VM but it did not actually exist in the
inventory it would never be removed.

This commit:
- Immediately exits the check_pool if an error occurs during inventory
  collection
- Will mark a VM as completed if it exists in Redis, but does not exist in
  inventory
- Adds tests for these behaviours
2017-07-18 16:53:16 -07:00
Glenn Sarti
b500814c69 (maint) Update flaky test
Sometimes this test would fail if the computer running the tests was under a
bit of load.  This commit changes the expected output to be up to 1.99 seconds
instead of the previous 0.99 seconds.
2017-07-18 15:28:39 -07:00
Rob Braden
9b0e55f959 Merge pull request #227 from glennsarti/add-check-skew
(GH-226) Use a dynamic pool_check loop period
2017-07-12 23:19:51 -07:00
Glenn Sarti
30946fab8e (GH-226) Use a dynamic pool_check loop period
Previously the check_pool would always check the pool every 5 seconds, however
with a large number of pools, this can cause resource issues inside the
providers.  This commit:
- Introduces a dynamic check_pool period which increases during stability and
  decreases when the pool is being change in an important way
- Surfaces the settings as global config defaults but can also be set on a per
  pool basis
- Adds defaults to emulate the current behaviour
- Unit tests for the new behaviour
2017-07-12 17:13:21 -07:00
kirby@puppetlabs.com
c750657c6f Update find_least_used_compatible_host to specify pool
This commit updates find_least_used_compatible_host method to specify
the pool name when evaluating a VM for migration. Without this change VM
migration fails with a wrong number of arguments error. Pool_manager
test references are updated to reflect the change.
2017-06-28 08:01:47 -07:00
Samuel Beaulieu
d93ab332f7 Adding support for multiple vsphere providers
Refactoring the vmpooler.yaml format to support multiple providers.
The second level key under :providers: is a unique key name that
represents a provider that can be refered in the pool's parameter
called provider. The code is still backward compatible to support
the :vsphere: and :dummy: keys but in reality if you have more than
one vsphere configuration you would give them a different name. For
example :vsphere-pdx: and :vsphere-bfs: and the actual provider
class would be specified as a parameter called 'provider_class'.
See tests and examples for more information.
2017-06-09 21:44:03 +01:00
Glenn Sarti
57eba4a8e4 (POOLER-70) Update execute! for VM Provider
This commit modifies execute! to create the VM Providers on VMPooler startup
instead of check_pool creating a provider per pool.  This commit also adds
legacy support for old configuration files:
- Setting the default provider for pools to be vsphere
- Copying VSphere connection settings in the configuration file from the legacy
  location in the root, to under :providers/:vsphere which is new location for
  all provider configuration
2017-05-17 13:52:28 -07:00
Glenn Sarti
1a3ae86943 (POOLER-70) Add config for VM Provider
This commit adds a public function to access the internal variable holding the
VMPooler configuration.  This is required for later commits for the execute!
function testing.
2017-05-17 13:52:28 -07:00
Glenn Sarti
2ca1a39e8c (POOLER-70) Update _check_pool for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Removes the MockFindFolder class as it is no longer required
- Minor update for rubocop violations
2017-05-17 13:52:28 -07:00
Glenn Sarti
7c3ad716af (POOLER-70) Update check_pool for VM Provider
Previously the Pool Manager would use a single VM provider per Pool.  This
commit changes Pool Manager to use a single provider that services multiple
pools.
2017-05-17 13:52:28 -07:00
Glenn Sarti
3f6ead8134 (POOLER-70) Update migrate_vm_and_record_timing for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the migrate_vm_and_record_timing method to use VM and Pool names
  instead of VM and Pool objects.
2017-05-17 13:52:28 -07:00
Glenn Sarti
cf15829f05 (POOLER-70) Remove get_vm_host_info from pool_manager
Previously the Pool Manager would use vSphere objects directly.  This commit
removes get_vm_host_info as this functionality is now in the vSphere VM
Provider.
2017-05-17 13:52:28 -07:00
Glenn Sarti
2974eac371 (POOLER-70) Update migrate_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
acf32a3f7b (POOLER-70) Update check_snapshot_queue for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
41f9d7b3c4 (POOLER-70) Update check_disk_queue for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
e01b96c6d0 (POOLER-70) Add get_provider_for_pool for VM Provider
This commit adds a helper method which retrieves the associated Provider object
for a pool by name
2017-05-17 13:52:28 -07:00
Glenn Sarti
c09035cfcb (POOLER-70) Add get_pool_name_for_vm for VM Provider
Previously there was no simple way to calculate which pool a VM was a member of.
This commit adds a helper method which queries redis for the pool name for a
given VM.
2017-05-17 13:52:27 -07:00
Glenn Sarti
c7b37dec75 (POOLER-70) Update revert_vm_snapshot for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
a56d61c8bf (POOLER-70) Update create_vm_snapshot for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
fd54c4ca18 (POOLER-70) Update create_vm_disk for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
64bca33d45 (POOLER-70) Update destroy_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the destroy_vm function into two.  One function spawns the thread
  while the other actually does the work.  This makes testing much easier.
2017-05-17 13:52:27 -07:00
Glenn Sarti
b21d78fa49 (POOLER-70) Update _clone_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
cc1910fd76 (POOLER-70) Update check_running_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
8c421aa3bd (POOLER-70) Update check_ready_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the check_ready_vm function into two.  One function spawns the thread
  while the other actually does the work.  This makes testing much easier.
2017-05-17 13:52:27 -07:00
Glenn Sarti
760dc1c67e (POOLER-70) Update move_pending_vm_to_ready for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
9f4fc903b9 (POOLER-70) Update fail_pending_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Modified to return true or false to indicate that the VM was failed
2017-05-17 13:52:27 -07:00
Glenn Sarti
199bf4a070 (POOLER-70) Update check_pending_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Removes the open_socket method and tests as it is only required in the vSphere
  VM provider
2017-05-17 13:52:27 -07:00
Glenn Sarti
5aa5019822 (POOLER-70) Add mock provider test fixture
This commit creates a VM Provider test fixture for spec tests that merely uses
the Base Provider class with a name of mock_provider.  This will then be used
by unit tests in further commits.
2017-05-17 13:52:27 -07:00
Glenn Sarti
ac8a34de86 (POOLER-70) Rename the use of vsphere to provider
VM provisioning will be handled by VM Providers.  This commit renames the use of
vsphere to provider where appropriate and changes the per-pool helper from
vsphere to providers to more accurately represent it's intended use.
2017-03-08 17:14:52 -08:00
Morgan Rhodes
850919f5db Merge pull request #189 from glennsarti/ticket/maint/rename-moves-and-clonevm
(POOLER-70) Refactor clone_vm to take pool configuration object
2017-03-02 11:39:29 -08:00
Glenn Sarti
ac7d7009d2 (POOLER-70) Refactor clone_vm to take pool configuration object
Previously, the clone_vm method took various VSphere specific parameters e.g.
template folder.  However in order make VMPooler less VSphere specific this
method should just take the pool configuration and then it can determine the
appropriate settings itself.  This commit also moves the threading to a clone_vm
while the actual method which does the work is now _clone_vm as per all other
multithread worker methods in pool_manager.  This commit also updates the spec
tests appropriately.
2017-03-01 21:53:42 -08:00
Glenn Sarti
f433056734 (GH-185) Remove unnecessary checks in check_ready_vm
Previously in check_ready_vm, if the VM is powered off, the VM is moved in
redis however the function doesn't return there, and instead then checks if the
hostname is the same, and then if TCP socket 22 is open. This is unnecessary as
we already know the VM is turned off so of course the hostname is wrong and TCP
22 is unavailable. The same applies for the VM hostname.

This commit instead returns after it is found a VM is no longer ready.  This
commit also amends the spec tests for the correct behaviour.
2017-03-01 20:28:36 -08:00
Glenn Sarti
e783e93784 (POOLER-73) Modify spec tests for _migrate_vm
Modify spec tests for _migrate_vm
2017-02-17 15:51:05 -08:00
Glenn Sarti
c69d61107f (POOLER-73) Modify spec tests for _revert_vm_snapshot
Modify spec tests for _revert_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
b63822fa9f (POOLER-73) Modify spec tests for _create_vm_snapshot
Modify spec tests for _create_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
0a6dffbd05 (POOLER-73) Add spec tests for _create_vm_disk
Add spec tests for _create_vm_disk
2017-02-17 15:51:05 -08:00
Glenn Sarti
3083186241 (POOLER-73) Add spec tests for _check_disk_queue
Add spec tests for _check_disk_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
25ad5d58f7 (POOLER-73) Add spec tests for _check_snapshot_queue
Add spec tests for _check_snapshot_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
6f127d32bc (POOLER-73) Add spec tests for check_snapshot_queue
Add spec tests for check_snapshot_queue

Previously the check_snapshot_queue method would execute the loop indefinitely
as it did not have a terminating condition.  This made it impossible to test.
This commit modifies the check_snapshot_queue method so that it can take a
maxloop and delay parameter so that it can be tested.
2017-02-17 15:51:05 -08:00
Glenn Sarti
4dd0c96a78 (POOLER-73) Add spec tests for check_disk_queue
Add spec tests for check_disk_queue

Previously the check_disk_queue method would execute the loop indefinitely as it
did not have a terminating condition.  This made it impossible to test.  This
commit modifies the check_disk_queue method so that it can take a maxloop and
delay parameter so that it can be tested.
2017-02-17 15:51:04 -08:00
Glenn Sarti
47d597f68a (POOLER-73) Add spec tests for migrate_vm_and_record_timing
Add spec tests for migrate_vm_and_record_timing
2017-02-17 15:51:04 -08:00
Glenn Sarti
fb6be8e079 (POOLER-73) Add spec tests for remove_vmpooler_migration_vm
Add spec tests for remove_vmpooler_migration_vm
2017-02-17 15:51:04 -08:00
Glenn Sarti
a4c55d5bf4 (POOLER-73) Add spec tests for migration_limit
Add spec tests for migration_limit
2017-02-17 15:51:04 -08:00
Glenn Sarti
925071be79 (POOLER-73) Add spec tests for migrate_vm
Add spect tests for migrate_vm
2017-02-17 15:51:04 -08:00