We provision nodes using the "Launch Agent using Command on Controller" option in the node settings. This will call a script which creates a node in our internal cloud and starts the agent. The script takes 30 minutes to an hour to get a node, set it up and start the agent.
We also use the "Bring this agent online according to a schedule" in the "Availability" option. When we use this option, Jenkins keep checking if the node is online every couple of minutes and triggers another execution of the script without waiting for the first execution to complete (i.e. agent startup). This ends up creating multiple executions and overwhelms our cluster. Attached screenshot to give an idea.
From the log:
/var/log/jenkins/jenkins.log.1:2021-07-13 03:50:32.709+0000 [id=45] INFO h.s.SimpleScheduledRetentionStrategy#check: Trying to launch computer S1 as schedule says it should be on-line at this point in time
/var/log/jenkins/jenkins.log.1:2021-07-13 03:52:32.707+0000 [id=46] INFO h.s.SimpleScheduledRetentionStrategy#check: Trying to launch computer S2 as schedule says it should be on-line at this point in time
How can I stop Jenkins from not triggering the same script multiple times over and wait for the first execution to complete?