Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Handling resources - block a resource #4589

chrisnak ·

We have a need where we want to block a resource from being used and when specified conditions are met, unblock it.
Is there a way to set a resource's count to 0 via a groovy script and then set it back to its original value?
Or is there a smarter way to achieve that behavior?

  • solved #6
  • replies 6
  • views 336
  • stars 0
robinshen ADMIN ·

There is no built-in mechanism for this. May I know your use case?

drdt ·

What if you have the resource count be a groovy script that returns either zero if the condition is true, and 1 (or the value of your choice) if it is false?

I have a resource that calculates the resource count as "(processor_count - 1)/3" to allow larger machines to take a higher workload. This would just be an extension of that paradigm.

What is the actual condition you want to trigger the change?

chrisnak ·

@robinshen
So in our system we have 2 types of configurations, normal configurations and special-purpose configurations.
The main difference is that the special ones run on specified agents, while the normal ones run on server.
For each special configuration we have a specific resource that is consumed at the master step and released when the configuration is complete. That way we prevent other configurations to interact with our agents while they are in use.

The problem arises on a very random time-window that a scheduled normal configuration interacts with an agent and changes its state (for instance shutting it down) and a scheduled special configuration starts while the agent's state is being altered and before the agent is shut down. Then the special configuration would fail when the agent is shutdown.

My ideal scenario would be that when a normal configuration starts, which will do stuff on our agents, we consume the specified resource (or block it from being used) or reserved it somehow. But I understand that I should find another way.

@drdt I believe this won't work because the scheduled special configurations couldn't tell if the resource is being in use and this needs to be added in every special configuration rather than be in a single place like the resources.

robinshen ADMIN ·

I understand that the normal configurations need to do some maintenance work on agents. If so, how about below approach:

  1. Add another resource with count 1 on each agent
  2. Set up the the maintenance step of normal configurations to require that resource
  3. Set up each special configuration to also require above resource (via nested composition steps) besides existing resource.
chrisnak ·

Thanks for your suggestion Robin, but it will require a lot of work for our 80++ agents setup.
I managed to make a working proof of concept as following:

  1. I added the resource that a special configuration consumes on the agents as a user attribute (More than 1 agent can be used in one special config).
  2. The normal configuration will create a list of the agents, on which we will run maintenance tasks and save it on a temporarily QuickBuild variable.
  3. Then a composition step will iterate over this list and execute the maintenance step(s).
  4. The maintenance step(s) will require the resource, which is read from the agents attributes.

I think that is the easiest solution so far that will require one time setup and nearly zero maintenance work. But I still need to tackle a few issues, like defaulting to a resource if the agent's attribute is not properly setup.

robinshen ADMIN ·

Thanks for sharing the idea. This looks smart to me.