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
Describe the bug
When starting a self hosted runner with ./run.cmd --once, the runner sometimes accepts a second job before shutting down, which causes that second job to fail with the message:
The runner: [runner-name] lost communication with the server. Verify the machine is running and has a healthy network connection.
Create a repo, enable GitHub Actions, and add a new workflow
Configure a new runner on your machine
Run the runner with ./run.cmd --once
Queue two runs of your workflow
The first job will run and the runner will go offline
(Optionally) configure and start a second runner
The second job will time out after several minutes with the message:
The runner: [runner-name] lost communication with the server. Verify the machine is running and has a healthy network connection.
(where [runner-name] is the name of the first runner)
Also: trying to remove the first runner with the command ./config.cmd remove --token [token] will result in the following error until the second job times out:
Failed: Removing runner from the server
Runner "[runner-name]" is running a job for pool "Default"
Expected behavior
The second job should run on (and wait for) any new runner that comes online rather than try to run as a second job on the, now offline, original runner.
Reacted by Billy Shambrook, Alexander Ziborov, Filip Hesslund, Vilsol, Hutson Betts, Daisuke Takahashi, Johannes Nicolai, Neil H Watson, Vinicius Schettino, Jordan Sussman and 47 more
@MatisseHack
How did you find the flag? 😆
the run once flag --once is not in the official actions doc and better not be used in production, there is a known issue that we haven't fix. 😄
Yeah, this is why it's not part of the documentation or command line help. Because the partially implemented code doesn't work and has races so we didn't ship it.
We have work on the backlog to register a runner with the service as ephemeral. It has to be a service side feature so the service is cooperative and doesn't assign it another job in the window when the runner or outside / in automation decides to tear it down.
I've used the --once flag extensively with Azure Pipelines to create an automatically scaling pool of single use agents. I'm trying to convert that system to work with GitHub Actions. I was pleased to find that the flag still worked (at least partially)!
Makes sens why it wasn't shipped 😄 . I look forward to using it when it's supported though!
We solved this issue by adding a timeout to our ephemeral workers. The timeout will deregister and kill the worker.
#!/bin/bash -xset -eux
/usr/bin/actions/register
# Automatically de-register in 30 minecho"sudo /usr/bin/actions/deregister && sudo shutdown -h now"| at now + 30 minutes
sudo -i -u actions /home/actions/run.sh --once
/usr/bin/actions/deregister
shutdown -h now
Actions team: please support --once when you have a chance!
We currently have ~16x parallelization on our CI to keep builds under 20 minutes. When moving to self-hosted, we had the following options:
Have an autoscaling group that keeps 16 instances around at the minimum and deploy more at peak times (this is a huge waste of money, it's hard to scale out and we have no clue how to scale-in without affecting existing jobs).
Make a Github-hosted job that deploys spot instances to perform the other jobs! This is substantially cheaper, avoids queues at peak times and allows us to parallelize even more when we need to!
Unfortunately, the second strategy only works well with --once...
So please consider supporting --once officially! If --once stops working, we'll probably have to consider an alternative CI provider.
Reacted by Jacob Parker, Oleksandr Piekhota, Adi Roiban, Charles Duffy, magnublo, Niek Palm, Magnus Longva, Uilton Oliveira, David Behnke, Futa HIRAKOBA and 6 more
We also use the --once flag as we need a fresh build environment for each build (on AArch64, so we can't use GitHub hosted runners), and while we haven't encountered this issue yet it'd be really nice to get proper support!
Reacted by Alex H. Raber, Andy Hsieh, Rodrigo Menezes, Jim Razmus II, WilliamDuTrendMicro, arash-bizcover, Magnus Longva, Croydon Dias, kub0x, David Maas and 2 more
Also @bryanmacfarlane - two more requests that would make ephermeral workers easier:
Have --once workers automatically de-register themselves on completion / timeout. Currently, if a worker errors out before cleanup code, you'll have a ton of zombie "offline" registered workers. I think this needs to be solved on the backend.
If no workers are registered with the proper labels, Github will error out the job immediately. This is a problem if you're spinning up ephemeral workers, because the job will error before they boot up.
Our hackish solution is to keep a registered worker that does no work:
It simply re-registers itself once a day to avoid the 30 day cleanup 😂
Thanks!
Reacted by Andrea Benfatto, Oleksandr Piekhota, Ville Väänänen, Croydon Dias and David Burela
@rclmenezes ack on #1 and #2. we're currently designing and working on it. The plan is exactly what you laid out, register the runner ephemeral with the backend service so the service auto cleans it up after the job is complete and the runner / container exits.
Reacted by Rodrigo Menezes, Steven White, Pauli Jokela, Hutson Betts, Jim Razmus II, Jeff McCune, Oleksandr Piekhota, Kyle Carberry, Nick Tan, Jonan and 2 more
Reacted by Rodrigo Menezes, Danny Guo, deanrock, Daniel Spiewak and Jonan
Forgot to mention but this would also make it easy to run on non-x86 architectures. LXD was similarly used to build up the foreign architecture support of Travis-CI where it's used to run arm64, ppc64el and s390x instances. Something similar could easily be done with Github actions if it wasn't for this limitation :)
Reacted by Paride Legovini, Tom Parrott and devops-gorillas
Reacted by Temtaime, Josh Bonfield, Frank Yi, Paulo Fagiani, Adrian Lee, Preston Zaugg, Wes McNamee, or-atnv, David J. M. Karlsen, Croydon Dias and 14 more
Reacted by Alex Deymo, Paride Legovini, Helio Machado, James Kennedy, Matisse Hack, Hideki Igarashi, Rodrigo Menezes, Ward Boumans, Martín Montenegro and Aidan Melen
Reacted by Helio Machado, Matisse Hack, Rodrigo Menezes and Martín Montenegro
It seems like the --once flag is still around and I'd like to ask keeping it around.
Registering an --ephemeral runner as part of a webhook, sure has it's own right to exist.
--once seems to cater for a different use case:
Have the action user home dir and actions working dir in a tempfs.
Reinitialize that tempfs with every run (matching the clean slate the cloud hosted runners produce)
This includes a non ephemeral registration.
Run above in a loop
That doesn't work with the ephemeral system because the registration token expires. While you don't need a registration token in the other case as the registration stays valid.
We're using this to use the same workflows across both cloud and a self hosted runners, because some builds have tie in to the enterprise network (for the time being).
Reacted by Rvalentine, Mark Adamson, Eran Rom, David Corrigan, Nathan Weeks, mengdilin, Kouji Matsui and Lucas Franceschino
@pje I'd like to confirm that there is no way to guarantee which workflow an ephemeral runner will pick up in case there are several runners are starting simultaneously for several workflow_job events. I've created a separate feature request #2106 to allow specify a workflow id for a runner to pick.
Activity
TingluoHuang commentedon May 30, 2020
@MatisseHack
How did you find the flag? 😆
the run once flag
--onceis not in the official actions doc and better not be used in production, there is a known issue that we haven't fix. 😄bryanmacfarlane commentedon May 30, 2020
Yeah, this is why it's not part of the documentation or command line help. Because the partially implemented code doesn't work and has races so we didn't ship it.
We have work on the backlog to register a runner with the service as ephemeral. It has to be a service side feature so the service is cooperative and doesn't assign it another job in the window when the runner or outside / in automation decides to tear it down.
MatisseHack commentedon Jun 1, 2020
I've used the
--onceflag extensively with Azure Pipelines to create an automatically scaling pool of single use agents. I'm trying to convert that system to work with GitHub Actions. I was pleased to find that the flag still worked (at least partially)!Makes sens why it wasn't shipped 😄 . I look forward to using it when it's supported though!
rclmenezes commentedon Jun 7, 2020
We solved this issue by adding a timeout to our ephemeral workers. The timeout will deregister and kill the worker.
Actions team: please support
--oncewhen you have a chance!We currently have ~16x parallelization on our CI to keep builds under 20 minutes. When moving to self-hosted, we had the following options:
Have an autoscaling group that keeps 16 instances around at the minimum and deploy more at peak times (this is a huge waste of money, it's hard to scale out and we have no clue how to scale-in without affecting existing jobs).
Make a Github-hosted job that deploys spot instances to perform the other jobs! This is substantially cheaper, avoids queues at peak times and allows us to parallelize even more when we need to!
Unfortunately, the second strategy only works well with
--once...So please consider supporting
--onceofficially! If--oncestops working, we'll probably have to consider an alternative CI provider.emilyalbini commentedon Jun 8, 2020
We also use the
--onceflag as we need a fresh build environment for each build (on AArch64, so we can't use GitHub hosted runners), and while we haven't encountered this issue yet it'd be really nice to get proper support!rclmenezes commentedon Jun 10, 2020
Also @bryanmacfarlane - two more requests that would make ephermeral workers easier:
Have
--onceworkers automatically de-register themselves on completion / timeout. Currently, if a worker errors out before cleanup code, you'll have a ton of zombie "offline" registered workers. I think this needs to be solved on the backend.If no workers are registered with the proper labels, Github will error out the job immediately. This is a problem if you're spinning up ephemeral workers, because the job will error before they boot up.
Our hackish solution is to keep a registered worker that does no work:
It simply re-registers itself once a day to avoid the 30 day cleanup 😂
Thanks!
nabilcode commentedon Jun 18, 2020
👋 there,
Do we have a date as to which the
--oncewould be supported?zacker150 commentedon Jul 6, 2020
It looks GitHub changed the runner service to error out the actions if there are no live runners. This hackish solution no longer works☹️ .
rclmenezes commentedon Jul 9, 2020
This really sucks. It's the last nail in the coffin for ephemeral self-hosted workers.
We're going to switch to permanent self-hosted workers and then probably switch to another CI provider :(
bryanmacfarlane commentedon Jul 10, 2020
@rclmenezes ack on #1 and #2. we're currently designing and working on it. The plan is exactly what you laid out, register the runner ephemeral with the backend service so the service auto cleans it up after the job is complete and the runner / container exits.
[-]Run once runner accepts a second job[/-][+]Ephemeral (single use) runner registrations[/+]11 remaining items
stgraber commentedon Jan 28, 2021
Forgot to mention but this would also make it easy to run on non-x86 architectures. LXD was similarly used to build up the foreign architecture support of Travis-CI where it's used to run arm64, ppc64el and s390x instances. Something similar could easily be done with Github actions if it wasn't for this limitation :)
xriu commentedon Feb 9, 2021
Any updates on this?
kylecarbs commentedon Feb 10, 2021
@bryanmacfarlane any updates on this?
0x2b3bfa0 commentedon Feb 14, 2021
We would like to use this feature as part of CML for running ephemeral continuous integration jobs.
david-behnke commentedon Feb 17, 2021
Not having a deterministic build environment is a show stopper for us 👎
rclmenezes commentedon Mar 26, 2021
Help us @bryanmacfarlane, you're our only hope! 🙏
korotovsky commentedon Aug 20, 2021
We are experiencing this issue on plain hardware server with 10+ runners, any ideas how to fix it? No
--onceflag was used.aidan-mundy commentedon Sep 17, 2021
Is this resolved with the merge of #660?
joeyparrish commentedon Sep 17, 2021
I believe so.
pje commentedon Sep 20, 2021
Closing this as #660 has been merged,
--ephemeralsupport has been fully deployed, and the docs have been updated. 🎉Implement changes for emphemeral fix of actions runner. actions/runne…
Ephemeral multiconf
spangaer commentedon May 11, 2022
It seems like the
--onceflag is still around and I'd like to ask keeping it around.Registering an
--ephemeralrunner as part of a webhook, sure has it's own right to exist.--onceseems to cater for a different use case:This includes a non ephemeral registration.
That doesn't work with the ephemeral system because the registration token expires. While you don't need a registration token in the other case as the registration stays valid.
We're using this to use the same workflows across both cloud and a self hosted runners, because some builds have tie in to the enterprise network (for the time being).
fkorotkov commentedon Sep 8, 2022
@pje I'd like to confirm that there is no way to guarantee which workflow an ephemeral runner will pick up in case there are several runners are starting simultaneously for several
workflow_jobevents. I've created a separate feature request #2106 to allow specify a workflow id for a runner to pick.