(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

@ -294,6 +294,12 @@ module Vmpooler
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is listed as running, but has no checkouttime data. Removing from running')
end
# tag VM if not tagged yet, this ensures the method is only called once
unless redis.hget("vmpooler__vm__#{vm}", 'user_tagged')
success = provider.tag_vm_user(pool, vm)
redis.hset("vmpooler__vm__#{vm}", 'user_tagged', 'true') if success
end
throw :stop_checking if provider.vm_ready?(pool, vm)
throw :stop_checking if provider.get_vm(pool, vm)