Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(POOLER-191) Add checking for running instances that are not in active #418

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/vmpooler/pool_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,15 @@ def _check_running_vm(vm, pool, ttl, provider)
move_vm_queue(pool, vm, 'running', 'completed', redis, "reached end of TTL after #{ttl} hours")
throw :stop_checking
end
else
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is listed as running, but has no checkouttime data. Removing from running')
end

if provider.vm_ready?(pool, vm)
throw :stop_checking
else
host = provider.get_vm(pool, vm)
throw :stop_checking if provider.vm_ready?(pool, vm)

if host
throw :stop_checking
else
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is no longer in inventory, removing from running')
end
end
throw :stop_checking if provider.get_vm(pool, vm)

move_vm_queue(pool, vm, 'running', 'completed', redis, 'is no longer in inventory, removing from running')
end
end
end
Expand Down
12 changes: 10 additions & 2 deletions spec/unit/pool_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,20 @@
end

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|
expect(provider).to receive(:vm_ready?).and_return(true)
expect(redis.sismember("vmpooler__running__#{pool}", vm)).to be(true)
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

Expand Down