mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #271 from mattkirby/less_delta_disks
Ensure template deltas are created once
This commit is contained in:
commit
2f98b1bd7a
2 changed files with 35 additions and 4 deletions
|
|
@ -630,6 +630,13 @@ module Vmpooler
|
||||||
prepare_template(pool, provider)
|
prepare_template(pool, provider)
|
||||||
prepared_template = $redis.hget('vmpooler__template__prepared', pool['name'])
|
prepared_template = $redis.hget('vmpooler__template__prepared', pool['name'])
|
||||||
end
|
end
|
||||||
|
elsif prepared_template != pool['template']
|
||||||
|
if configured_template.nil?
|
||||||
|
mutex.synchronize do
|
||||||
|
prepare_template(pool, provider)
|
||||||
|
prepared_template = $redis.hget('vmpooler__template__prepared', pool['name'])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return if configured_template.nil?
|
return if configured_template.nil?
|
||||||
return if configured_template == prepared_template
|
return if configured_template == prepared_template
|
||||||
|
|
@ -901,8 +908,6 @@ module Vmpooler
|
||||||
$redis.set('vmpooler__tasks__clone', 0)
|
$redis.set('vmpooler__tasks__clone', 0)
|
||||||
# Clear out vmpooler__migrations since stale entries may be left after a restart
|
# Clear out vmpooler__migrations since stale entries may be left after a restart
|
||||||
$redis.del('vmpooler__migration')
|
$redis.del('vmpooler__migration')
|
||||||
# Ensure template deltas are created on each startup
|
|
||||||
$redis.del('vmpooler__template__prepared')
|
|
||||||
|
|
||||||
# Copy vSphere settings to correct location. This happens with older configuration files
|
# Copy vSphere settings to correct location. This happens with older configuration files
|
||||||
if !$config[:vsphere].nil? && ($config[:providers].nil? || $config[:providers][:vsphere].nil?)
|
if !$config[:vsphere].nil? && ($config[:providers].nil? || $config[:providers][:vsphere].nil?)
|
||||||
|
|
|
||||||
|
|
@ -1838,8 +1838,26 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when prepared template is nil' do
|
context 'when prepared template is nil' do
|
||||||
before(:each) do
|
|
||||||
|
it 'should prepare the template' do
|
||||||
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(nil)
|
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(nil)
|
||||||
|
expect(subject).to receive(:prepare_template).with(config[:pools][0], provider)
|
||||||
|
|
||||||
|
subject.evaluate_template(config[:pools][0], provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not prepare the template again' do
|
||||||
|
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
|
||||||
|
expect(subject).to_not receive(:prepare_template).with(config[:pools][0], provider)
|
||||||
|
|
||||||
|
subject.evaluate_template(config[:pools][0], provider)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the configured pool template does not match the prepared template' do
|
||||||
|
before(:each) do
|
||||||
|
config[:pools][0]['template'] = new_template
|
||||||
|
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should prepare the template' do
|
it 'should prepare the template' do
|
||||||
|
|
@ -1847,6 +1865,15 @@ EOT
|
||||||
|
|
||||||
subject.evaluate_template(config[:pools][0], provider)
|
subject.evaluate_template(config[:pools][0], provider)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'if configured_template is provided' do
|
||||||
|
it 'should not run prepare_template' do
|
||||||
|
expect(redis).to receive(:hget).with('vmpooler__config__template', pool).and_return(current_template)
|
||||||
|
expect(subject).to_not receive(:prepare_template)
|
||||||
|
|
||||||
|
subject.evaluate_template(config[:pools][0], provider)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a new template is requested' do
|
context 'when a new template is requested' do
|
||||||
|
|
@ -2299,7 +2326,6 @@ EOT
|
||||||
it 'should run startup tasks only once' do
|
it 'should run startup tasks only once' do
|
||||||
expect(redis).to receive(:set).with('vmpooler__tasks__clone', 0).once
|
expect(redis).to receive(:set).with('vmpooler__tasks__clone', 0).once
|
||||||
expect(redis).to receive(:del).with('vmpooler__migration').once
|
expect(redis).to receive(:del).with('vmpooler__migration').once
|
||||||
expect(redis).to receive(:del).with('vmpooler__template__prepared').once
|
|
||||||
|
|
||||||
subject.execute!(maxloop,0)
|
subject.execute!(maxloop,0)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue