mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 10:28:41 -05:00
(POOLER-123) Implement a max TTL
Before this change, we could checkout a vm and set the lifetime to a very high number which would esssentially keep the vm running forever. Now implementing a config setting max_lifetime_upper_limit which enforces a maximum lifetime in hours both for initial checkout and extending a running vm
This commit is contained in:
parent
86dbc783ef
commit
ac17284a61
4 changed files with 63 additions and 1 deletions
|
|
@ -20,12 +20,14 @@ describe Vmpooler::API::V1 do
|
|||
config: {
|
||||
'site_name' => 'test pooler',
|
||||
'vm_lifetime_auth' => 2,
|
||||
|
||||
},
|
||||
pools: [
|
||||
{'name' => 'pool1', 'size' => 5},
|
||||
{'name' => 'pool2', 'size' => 10}
|
||||
],
|
||||
alias: { 'poolone' => 'pool1' },
|
||||
auth: false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +36,6 @@ describe Vmpooler::API::V1 do
|
|||
before(:each) do
|
||||
app.settings.set :config, config
|
||||
app.settings.set :redis, redis
|
||||
app.settings.set :config, auth: false
|
||||
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
|
||||
end
|
||||
|
||||
|
|
@ -122,6 +123,41 @@ describe Vmpooler::API::V1 do
|
|||
vm = fetch_vm('testhost')
|
||||
expect(vm['lifetime']).to be_nil
|
||||
end
|
||||
|
||||
it 'does not enforce a lifetime' do
|
||||
create_vm('testhost')
|
||||
|
||||
put "#{prefix}/vm/testhost", '{"lifetime":"20000"}'
|
||||
expect_json(ok = true, http = 200)
|
||||
|
||||
vm = fetch_vm('testhost')
|
||||
expect(vm['lifetime']).to eq("20000")
|
||||
end
|
||||
|
||||
it 'does not allow a lifetime to be initially past config 168' do
|
||||
app.settings.set :config,
|
||||
{ :config => { :max_lifetime_upper_limit => 168 } }
|
||||
create_vm('testhost')
|
||||
|
||||
put "#{prefix}/vm/testhost", '{"lifetime":"200"}'
|
||||
expect_json(ok = false, http = 400)
|
||||
|
||||
vm = fetch_vm('testhost')
|
||||
expect(vm['lifetime']).to be_nil
|
||||
end
|
||||
|
||||
it 'does not allow a lifetime to be extended past config 168' do
|
||||
app.settings.set :config,
|
||||
{ :config => { :max_lifetime_upper_limit => 168 } }
|
||||
create_vm('testhost')
|
||||
|
||||
set_vm_data('testhost', "checkout", (Time.now - (69*60*60)))
|
||||
put "#{prefix}/vm/testhost", '{"lifetime":"100"}'
|
||||
expect_json(ok = false, http = 400)
|
||||
|
||||
vm = fetch_vm('testhost')
|
||||
expect(vm['lifetime']).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context '(auth configured)' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue