You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cml-runner: Add an option to reuse only idle runners #575
Today, the --reuse option of cml-runner does not care if the runner is in use or not.
While it is convenient when multiple jobs can be run on the same runner, some job needs a dedicated runner to work (jobs that take the runner resources).
However, we could benefit from runner reusability for this kind of job by introducing a --reuse-idle option to the runner. This option would reuse a runner only if it is idle (option naming to be challenged).
Reacted by Helio Machado, Benjamin Jones and Casper da Costa-Luis
Github returns an is_busy boolean that is false when the runner is idle (see the doc).
We can pass is_idle in opts and filter runners depending on this value, here:
I wasn't able to test it on gitlab but they seem to have an active field (see the doc).
However I was not able to see the signification of this active, can someone with a gitlab repo and runner setup help me to make sure this field checks runner idle-ness, maybe @DavidGOrtega ?
So true, we already face this possible race condition. I guess that it would be a minor issue to live with: the worst case would imply feeding a single runner with two tasks serially.
As I stated runners takes jobs, thats it. So when we launch a workflow that launches one machine and we have already a runner with those tags what will happen is that the job will be taken by any of the runners, thats why we cleanup runners after idle. One of the runners will remain idle until idle-timeout happens and the other will reach the same fatal destiny after completing the job and idle-timeout happens 😈
I don't fully understand what is being proposed here so feel free to re-open.
GitHub Actions will only distribute a job to a runner if it is idle, to run multiple jobs on a single instance you would need to register multiple runners as different independent services on the instance.
the --single flag will ensure that only a job is run. w/o this instance will continue to pick jobs matching its provided labels until the idle timeout is reached, after which it will self-terminate.
cml runner --labels=xyz --single: con: often have to wait 5min+ to provision
cml runner --labels=xyz --reuse: con: no parallel jobs (queue waiting for one runner)
cml runner --labels=xyz --reuse-idle: this feature request: no need to wait to provision iff another job has just completed (so an idle runner is available)
Seems very reasonable, so cml runner should try to check for an existing one if present exit successfully so the dependant job can get picked up. Though this is dangerous territory for a race condition.
I could see: 10 jobs get rapidly spawned, and there is 1 runner idle. The 10 jobs all do their check for idle runner and see one, so no new runner is created, a few seconds later, our existing runner has its new job but we have 9 waiting in the queue for that same runner.
Activity
courentin commentedon Jun 4, 2021
Implementation notes:
Github
Github returns an
is_busyboolean that isfalsewhen the runner is idle (see the doc).We can pass
is_idleinoptsand filter runners depending on this value, here:cml/src/drivers/github.js
Lines 233 to 245 in 75866d1
Gitlab
I wasn't able to test it on gitlab but they seem to have an
activefield (see the doc).However I was not able to see the signification of this
active, can someone with a gitlab repo and runner setup help me to make sure this field checks runner idle-ness, maybe @DavidGOrtega ?0x2b3bfa0 commentedon Jun 4, 2021
Thank you very much, @courentin! This could be a nice way for
cml-runnerto expedite runs triggered with--reuserunners.What would happen if the runner accepts another task between the idleness check and the task creation?
courentin commentedon Jun 4, 2021
I haven't thought about it, it will have the same behaviour than
--reusein this case.Not sure if we can avoid this?
0x2b3bfa0 commentedon Jun 4, 2021
So true, we already face this possible race condition. I guess that it would be a minor issue to live with: the worst case would imply feeding a single runner with two tasks serially.
DavidGOrtega commentedon Jun 8, 2021
As I stated runners takes jobs, thats it. So when we launch a workflow that launches one machine and we have already a runner with those tags what will happen is that the job will be taken by any of the runners, thats why we cleanup runners after idle. One of the runners will remain idle until idle-timeout happens and the other will reach the same fatal destiny after completing the job and idle-timeout happens 😈
DavidGOrtega commentedon Jun 8, 2021
We also have the option
--singledacbd commentedon May 12, 2022
I don't fully understand what is being proposed here so feel free to re-open.
GitHub Actions will only distribute a job to a runner if it is idle, to run multiple jobs on a single instance you would need to register multiple runners as different independent services on the instance.
the
--singleflag will ensure that only a job is run. w/o this instance will continue to pick jobs matching its provided labels until the idle timeout is reached, after which it will self-terminate.casperdcl commentedon May 31, 2022
use case explanation:
cml runner --labels=xyz --single: con: often have to wait 5min+ to provisioncml runner --labels=xyz --reuse: con: no parallel jobs (queue waiting for one runner)cml runner --labels=xyz --reuse-idle: this feature request: no need to wait to provision iff another job has just completed (so an idle runner is available)dacbd commentedon Jun 3, 2022
So with
--reuse-idleif:runneris registered with that labelrunneris idlecml runnerexits so the dependant job can get picked up without creating a new instance,casperdcl commentedon Jun 6, 2022
-- @casperdcl in #1025 (comment)
-- @dacbd in #1025 (comment)
prototype iterative/cml#575