mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Merge 38f962f514 into ad4e760f56
This commit is contained in:
commit
c78e8b68ca
4 changed files with 27 additions and 3 deletions
|
|
@ -33,6 +33,9 @@ module Vmpooler
|
||||||
parsed_config[:config]['vm_checktime'] ||= 15
|
parsed_config[:config]['vm_checktime'] ||= 15
|
||||||
parsed_config[:config]['vm_lifetime'] ||= 24
|
parsed_config[:config]['vm_lifetime'] ||= 24
|
||||||
|
|
||||||
|
parsed_config[:config]['check_pending_port'] ||= 22
|
||||||
|
parsed_config[:config]['check_pending_timeout'] ||= 5
|
||||||
|
|
||||||
# Create an index of pool aliases
|
# Create an index of pool aliases
|
||||||
parsed_config[:pools].each do |pool|
|
parsed_config[:pools].each do |pool|
|
||||||
if pool['alias']
|
if pool['alias']
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class PoolManager
|
class PoolManager
|
||||||
|
|
||||||
def initialize(config, logger, redis, graphite=nil)
|
def initialize(config, logger, redis, graphite=nil)
|
||||||
$config = config
|
$config = config
|
||||||
|
|
||||||
|
|
@ -32,8 +33,8 @@ module Vmpooler
|
||||||
|
|
||||||
if host
|
if host
|
||||||
begin
|
begin
|
||||||
Timeout.timeout(5) do
|
Timeout.timeout($config[:config]['check_pending_timeout']) do
|
||||||
TCPSocket.new vm, 22
|
TCPSocket.new vm, $config[:config]['check_pending_port']
|
||||||
end
|
end
|
||||||
move_pending_vm_to_ready(vm, pool, host)
|
move_pending_vm_to_ready(vm, pool, host)
|
||||||
rescue
|
rescue
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,20 @@ describe 'Pool Manager' do
|
||||||
context 'host is in pool' do
|
context 'host is in pool' do
|
||||||
let(:vm_finder) { double('vm_finder') }
|
let(:vm_finder) { double('vm_finder') }
|
||||||
let(:tcpsocket) { double('TCPSocket') }
|
let(:tcpsocket) { double('TCPSocket') }
|
||||||
|
# port and port timeout are now configurable.
|
||||||
|
# update the config mock
|
||||||
|
let(:port_no) { 99 }
|
||||||
|
let(:config) { {config: {
|
||||||
|
'check_pending_port' => port_no,
|
||||||
|
'check_pending_timeout' => 2}} }
|
||||||
|
|
||||||
it 'calls move_pending_vm_to_ready' do
|
it 'calls move_pending_vm_to_ready' do
|
||||||
stub_const("TCPSocket", tcpsocket)
|
stub_const("TCPSocket", tcpsocket)
|
||||||
|
|
||||||
allow(pool_helper).to receive(:find_vm).and_return(vm_finder)
|
allow(pool_helper).to receive(:find_vm).and_return(vm_finder)
|
||||||
allow(vm_finder).to receive(:summary).and_return(nil)
|
allow(vm_finder).to receive(:summary).and_return(nil)
|
||||||
allow(tcpsocket).to receive(:new).and_return(true)
|
# ensure the port config made it to the TCPSocket call:
|
||||||
|
allow(tcpsocket).to receive(:new).with(String, port_no).and_return(true)
|
||||||
|
|
||||||
expect(vm_finder).to receive(:summary).once
|
expect(vm_finder).to receive(:summary).once
|
||||||
expect(redis).not_to receive(:hget).with(String, 'clone')
|
expect(redis).not_to receive(:hget).with(String, 'clone')
|
||||||
|
|
@ -50,6 +57,7 @@ describe 'Pool Manager' do
|
||||||
subject._check_pending_vm(vm, pool, timeout)
|
subject._check_pending_vm(vm, pool, timeout)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#move_vm_to_ready' do
|
describe '#move_vm_to_ready' do
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,16 @@
|
||||||
#
|
#
|
||||||
# - domain
|
# - domain
|
||||||
# If set, returns a top-level 'domain' JSON key in POST requests
|
# If set, returns a top-level 'domain' JSON key in POST requests
|
||||||
|
#
|
||||||
|
# - check_pending_port
|
||||||
|
# The port number used to verify a host is ready and available.
|
||||||
|
# (optional; default: 22)
|
||||||
|
#
|
||||||
|
# - check_pending_timeout
|
||||||
|
# How long (in seconds) to wait for connection to port before canceling.
|
||||||
|
# This is not used in marking a VM dead or stale.
|
||||||
|
# (optional; default: 5)
|
||||||
|
#
|
||||||
|
|
||||||
# Example:
|
# Example:
|
||||||
|
|
||||||
|
|
@ -176,6 +186,8 @@
|
||||||
- 'created_by'
|
- 'created_by'
|
||||||
- 'project'
|
- 'project'
|
||||||
domain: 'company.com'
|
domain: 'company.com'
|
||||||
|
check_pending_port: 22
|
||||||
|
check_pending_timeout: 5
|
||||||
|
|
||||||
# :pools:
|
# :pools:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue