(maint) Adding a provider method tag_vm_user

This method should be called only once, when the VM is moved to a running state
which is when the data for the user (if using tokens) is available. In vmpooler
base provider it is a noop method, but the various providers can implement it
to tag or label a running VM with the name of the user who checked it out
This commit is contained in:
Samuel Beaulieu 2021-12-09 11:13:03 -06:00
parent 0777bd36d4
commit daea25b1d1
No known key found for this signature in database
GPG key ID: 12030F74136D0F34
3 changed files with 41 additions and 0 deletions

View file

@ -683,6 +683,25 @@ EOT
expect(redis.sismember("vmpooler__completed__#{pool}", vm)).to be(true)
end
end
it 'should try to tag if it has not been done' do
redis_connection_pool.with do |redis|
expect(provider).to receive(:vm_ready?).and_return(true)
redis.hset("vmpooler__active__#{pool}", vm,(Time.now - timeout*60*60).to_s)
expect(provider).to receive(:tag_vm_user)
subject._check_running_vm(vm, pool, 0, provider)
end
end
it 'should not try to tag if it has been done' do
redis_connection_pool.with do |redis|
expect(provider).to receive(:vm_ready?).and_return(true)
redis.hset("vmpooler__active__#{pool}", vm,(Time.now - timeout*60*60).to_s)
redis.hset("vmpooler__vm__#{vm}", 'user_tagged', 'true')
expect(provider).not_to receive(:tag_vm_user)
subject._check_running_vm(vm, pool, 0, provider)
end
end
end
context 'with a locked vm mutex' do