Hi, I have several jobs that require exlusive access to some resource of which 
a given agent node can have multiple, but limited to some maximum number which 
is less than nr of executors of the agent.
We solve this by using the Lockable Resources plugin. We define a resource per 
what is available on a node like: <res>_<nr>_<node>and give each of those 
resources a generic label 'VirtualRes'.In the job code we can then use:
     lock(label: 'VirtualRes', quantity: 1, variable: 'res_locked')     {     }
and within the code block, derive the nodename from the resource by string 
extraction, and assign the work to that node.
This normally works fine, until there is some issue with one of the nodes going 
offline.
As the LockableResources are defined on the master itself without any link to 
the node, the resources of any offline nodeare still available. Consequently a 
lock will be granted, but the worker job will be queued if the node is not 
online.
I am looking for a way to lock a resource with additional check that the node 
is online.

Due to [JENKINS-50176] my code for the lock already has some surrounding 
'retry()' loop with exception handling forthe res_locked being null. I could 
extend that (rather ugly) code to also check for the node being offline, but I 
am hopingthat there is a cleaner solution.Anyone ??
thx, M.
PS: Obviously, it would be so much nicer if lockable resources could be 
allocated in the node definition; then they would be unavailable if the node 
goes offline. And also having multiple of the same resource would be the latest 
request.






-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/775169529.312360.1590567499764%40mail.yahoo.com.

Reply via email to