mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Auto-expire summary index keys
This commit is contained in:
parent
6d06128481
commit
2e5fdc5200
4 changed files with 20 additions and 1 deletions
|
|
@ -544,6 +544,9 @@ module Vmpooler
|
||||||
arg.keys.each do |tag|
|
arg.keys.each do |tag|
|
||||||
backend.hset('vmpooler__vm__' + params[:hostname], 'tag:' + tag, arg[tag])
|
backend.hset('vmpooler__vm__' + params[:hostname], 'tag:' + tag, arg[tag])
|
||||||
backend.hset('vmpooler__tag__' + Date.today.to_s, params[:hostname] + ':' + tag, arg[tag])
|
backend.hset('vmpooler__tag__' + Date.today.to_s, params[:hostname] + ':' + tag, arg[tag])
|
||||||
|
|
||||||
|
# Auto-expire summary index
|
||||||
|
backend.expire('vmpooler__tag__' + Date.today.to_s, (Vmpooler::API.settings.config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,9 @@ module Vmpooler
|
||||||
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
||||||
$redis.hset('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm, finish)
|
$redis.hset('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm, finish)
|
||||||
|
|
||||||
|
# Auto-expire summary index
|
||||||
|
$redis.expire('vmpooler__boot__' + Date.today.to_s, ($config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||||
|
|
||||||
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -233,6 +236,9 @@ module Vmpooler
|
||||||
$redis.hset('vmpooler__clone__' + Date.today.to_s, vm['template'] + ':' + vm['hostname'], finish)
|
$redis.hset('vmpooler__clone__' + Date.today.to_s, vm['template'] + ':' + vm['hostname'], finish)
|
||||||
$redis.hset('vmpooler__vm__' + vm['hostname'], 'clone_time', finish)
|
$redis.hset('vmpooler__vm__' + vm['hostname'], 'clone_time', finish)
|
||||||
|
|
||||||
|
# Auto-expire summary index
|
||||||
|
$redis.expire('vmpooler__clone__' + Date.today.to_s, ($config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||||
|
|
||||||
$logger.log('s', "[+] [#{vm['template']}] '#{vm['hostname']}' cloned from '#{vm['template']}' in #{finish} seconds")
|
$logger.log('s', "[+] [#{vm['template']}] '#{vm['hostname']}' cloned from '#{vm['template']}' in #{finish} seconds")
|
||||||
rescue
|
rescue
|
||||||
$logger.log('s', "[!] [#{vm['template']}] '#{vm['hostname']}' clone appears to have failed")
|
$logger.log('s', "[!] [#{vm['template']}] '#{vm['hostname']}' clone appears to have failed")
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,10 @@ describe Vmpooler::API::V1 do
|
||||||
pools: [
|
pools: [
|
||||||
{'name' => 'pool1', 'size' => 5},
|
{'name' => 'pool1', 'size' => 5},
|
||||||
{'name' => 'pool2', 'size' => 10}
|
{'name' => 'pool2', 'size' => 10}
|
||||||
]
|
],
|
||||||
|
redis: {
|
||||||
|
'data_ttl' => '168'
|
||||||
|
}
|
||||||
} }
|
} }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
@ -310,6 +313,7 @@ describe Vmpooler::API::V1 do
|
||||||
app.settings.set :redis, redis
|
app.settings.set :redis, redis
|
||||||
|
|
||||||
allow(redis).to receive(:exists).and_return '1'
|
allow(redis).to receive(:exists).and_return '1'
|
||||||
|
allow(redis).to receive(:expire).with('vmpooler__tag__' + Date.today.to_s, 604800).and_return '1'
|
||||||
allow(redis).to receive(:hset).and_return '1'
|
allow(redis).to receive(:hset).and_return '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,17 @@ describe 'Pool Manager' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'a host with proper summary' do
|
context 'a host with proper summary' do
|
||||||
|
let(:config) { {
|
||||||
|
redis: { 'data_ttl' => '168' }
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(host).to receive(:summary).and_return true
|
allow(host).to receive(:summary).and_return true
|
||||||
allow(host).to receive_message_chain(:summary, :guest).and_return true
|
allow(host).to receive_message_chain(:summary, :guest).and_return true
|
||||||
allow(host).to receive_message_chain(:summary, :guest, :hostName).and_return vm
|
allow(host).to receive_message_chain(:summary, :guest, :hostName).and_return vm
|
||||||
|
|
||||||
|
allow(redis).to receive(:expire).with('vmpooler__boot__' + Date.today.to_s, 604800).and_return '1'
|
||||||
allow(redis).to receive(:hget)
|
allow(redis).to receive(:hget)
|
||||||
allow(redis).to receive(:smove)
|
allow(redis).to receive(:smove)
|
||||||
allow(redis).to receive(:hset)
|
allow(redis).to receive(:hset)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue