mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #418 from mattkirby/pooler_191
(POOLER-191) Add checking for running instances that are not in active
This commit is contained in:
commit
e600336a7e
2 changed files with 17 additions and 13 deletions
|
|
@ -289,23 +289,19 @@ module Vmpooler
|
||||||
move_vm_queue(pool, vm, 'running', 'completed', redis, "reached end of TTL after #{ttl} hours")
|
move_vm_queue(pool, vm, 'running', 'completed', redis, "reached end of TTL after #{ttl} hours")
|
||||||
throw :stop_checking
|
throw :stop_checking
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is listed as running, but has no checkouttime data. Removing from running')
|
||||||
end
|
end
|
||||||
|
|
||||||
if provider.vm_ready?(pool, vm)
|
throw :stop_checking if provider.vm_ready?(pool, vm)
|
||||||
throw :stop_checking
|
|
||||||
else
|
throw :stop_checking if provider.get_vm(pool, vm)
|
||||||
host = provider.get_vm(pool, vm)
|
|
||||||
|
|
||||||
if host
|
|
||||||
throw :stop_checking
|
|
||||||
else
|
|
||||||
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is no longer in inventory, removing from running')
|
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is no longer in inventory, removing from running')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def move_vm_queue(pool, vm, queue_from, queue_to, redis, msg = nil)
|
def move_vm_queue(pool, vm, queue_from, queue_to, redis, msg = nil)
|
||||||
redis.smove("vmpooler__#{queue_from}__#{pool}", "vmpooler__#{queue_to}__#{pool}", vm)
|
redis.smove("vmpooler__#{queue_from}__#{pool}", "vmpooler__#{queue_to}__#{pool}", vm)
|
||||||
|
|
|
||||||
|
|
@ -647,12 +647,20 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'valid host' do
|
context 'valid host' do
|
||||||
it 'should not move VM if it has no checkout time' do
|
it 'should kill a VM if it has no checkout time' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
expect(provider).to receive(:vm_ready?).and_return(true)
|
expect(provider).to receive(:vm_ready?).and_return(true)
|
||||||
expect(redis.sismember("vmpooler__running__#{pool}", vm)).to be(true)
|
expect(redis.sismember("vmpooler__running__#{pool}", vm)).to be(true)
|
||||||
subject._check_running_vm(vm, pool, 0, provider)
|
subject._check_running_vm(vm, pool, 0, provider)
|
||||||
expect(redis.sismember("vmpooler__running__#{pool}", vm)).to be(true)
|
expect(redis.sismember("vmpooler__running__#{pool}", vm)).to be(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should log a message when the machine is removed due to no active data' do
|
||||||
|
redis_connection_pool.with do |redis|
|
||||||
|
expect(provider).to receive(:vm_ready?).and_return(true)
|
||||||
|
expect(logger).to receive(:log).with('d',"[!] [#{pool}] '#{vm}' is listed as running, but has no checkouttime data. Removing from running")
|
||||||
|
subject._check_running_vm(vm, pool, 0, provider)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue