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
Add support for resources requests and limits #100
The actions runner controller allows me to run a bunch of github agents waiting for container jobs in k8.
As these agents don't really do anything it would be good if I could keep a whole bunch of these agents running ready to pick up jobs as and when required with minimal resource requests.
resources:
requests:
cpu: 5m
memory: 150Mi
I would then like the container jobs to define the amount of resources they want for each container and for this information to be passed through to the container spec.
This would be very useful as we would not have to keep warm compute running for all the different permutations of required resources for out jobs and could just keep an amount of warm low priority compute to be share by all the different jobs.
Unfortunately there is no resources property for either a container or a service but maybe we can supply this information via the env property, something like.
Thank you for submitting this issue so clearly! There is an ongoing work right now to allow merges and customization of container specs. But based on your description, I can see that it can't fit all cases well, especially for different workflows requiring different sets of limits and requests based on containers it needs to spin up.
Right now, I would prefer the env approach. It would eliminate changes in the workflow yaml file, but can carry a special meaning to the hook. I will bring this up to the team, but it seems like a great suggestion to me
@nikola-jokic I'm not sure how the overrides that were introduced in 0.4.0 (and refined in later versions) fixes this specific issue. The template overrides that can be provided for containers are great for static mutations like imagePullSecrets, sidecars, volumets, etc.
The overrides however do not allow for dynamic resource setting as originally proposed in the issue. Static resources could be added with the $job entry but that would only allow a user to provide every job container with the same resource requests/limits. If pulling information from the container env variables is not ideal, it would be a nice middle ground to have the job resource request/limits set from reading the --cpus and --memory options from the jobs.*.container.options.
I think this issue should be reopend until proper support is in place or is stated as not going to be supported.
Reacted by Tomislav Blažeka, Ravelle Kelley, Andrii Shevchyk, Alexis Coles, Carl Thuringer, Borislav Velkov, Jason Barnett and Anatoly Leskovets
One more vote for re-opening the issue. We are using the template for jobs but if the pod is too big and there is no space on the runner node we get errors. This shouldn't work like that. The runner pod should be minimal and just scheduling pods with the desired resources.
Update the runner-container-hooks to dynamically add podAffinity using the label selector matching the ephemeral runner name
With this change plus setting ACTIONS_RUNNER_USE_KUBE_SCHEDULER to true, this should guarantee the the pod is spun up on the same node as the ephemeral runner pod. Even if resources aren't immediately available it would continue to try to be scheduled.
Lastly, I think I can modify runner-container-hooks to pull out a nested YAML structure from jobs.<job_id>.container.options and apply it to the -workflow pod spec allowing for dynamic cpu and memory requests.
name: CIon:
push:
branches: [ main ]jobs:
container-test-job:
runs-on: ubuntu-latestcontainer:
image: node:18options: | resources: requests: memory: "64Mi" cpu: "250m" limits: memory: "128Mi" cpu: "500m"steps:
- name: Check for dockerenv filerun: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
Ideally the jobs.<job_id>.container spec would be extended with a new key, but without that I could hack the existing schema and make it all work.
That still seems like a workaround and there are edge cases where it might never work, i.e. the workflow pod being bigger than the node the runner is on.
Is there any possibility to work towards a different method than the PVC to share information, as those limitations stem from it?
There should definitely be some work around supporting runners working on different nodes as well. The limitation for them running on the same node is far from ideal and always going to cause some issues.
But either way the work for defining the resources in the workflow and getting that applied to the workflow container would be a great enhancement. Using the options seems a sensible way to go. 👍
Also bumping this up with the support for re-opening.
As there is an ongoing attempt to get PVCless (#244), some of the concerns from above will not be a problem.
However, letting the workflow pod specify the resources needed for a run would add a lot of flexibility and freedom for workflows design.
So far, this can be achieved with either providing runners with pre-defined specs (populated via $job) or by overriding ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE with the path to yaml file (For different templates, different files have to be present on the runner before hand, making it impossible to change it "on the fly").
@nikola-jokic would that be possible to allow workflow pods to read resources and limits from the workflow file directly?
Adding to the reopen requests above — the 0.4.0 hook-template overrides are per runner set, so they can't size an individual job. GitLab's Kubernetes executor solves exactly this, and the same shape would fit the k8s hook here:
Job-level hints, read by the hook in prepare_job from the job container's env, e.g.
Admin ceilings in the hook template / runner-set env (like GitLab's *_OVERWRITE_MAX_ALLOWED), so a workflow can't request more than the cluster operator allows; absent hints = template default.
The job pod is then created with those requests/limits, so the scheduler queues it when the node is full instead of OOM-killing it, and runner pods can stay tiny (the original ask).
Use case: a self-hosted ARC pool where builds need 4–6 GiB but most jobs need <1 GiB; per-set sizes force either over-reservation or one runner set per size.
Activity
[-]Adding support for resources requests and limits[/-][+]Add support for resources requests and limits[/+]nikola-jokic commentedon Aug 16, 2023
Hey @AlexisColes,
Thank you for submitting this issue so clearly! There is an ongoing work right now to allow merges and customization of container specs. But based on your description, I can see that it can't fit all cases well, especially for different workflows requiring different sets of limits and requests based on containers it needs to spin up.
Right now, I would prefer the env approach. It would eliminate changes in the workflow yaml file, but can carry a special meaning to the hook. I will bring this up to the team, but it seems like a great suggestion to me
nikola-jokic commentedon Oct 2, 2023
Hey, closing this issue since it has been fixed with 0.4.0 release allowing definition overrides☺️
jmccarty3 commentedon Apr 12, 2024
@nikola-jokic I'm not sure how the overrides that were introduced in 0.4.0 (and refined in later versions) fixes this specific issue. The template overrides that can be provided for containers are great for static mutations like imagePullSecrets, sidecars, volumets, etc.
The overrides however do not allow for dynamic resource setting as originally proposed in the issue. Static resources could be added with the $job entry but that would only allow a user to provide every job container with the same resource requests/limits. If pulling information from the container env variables is not ideal, it would be a nice middle ground to have the job resource request/limits set from reading the
--cpusand--memoryoptions from thejobs.*.container.options.I think this issue should be reopend until proper support is in place or is stated as not going to be supported.
velkovb commentedon Dec 17, 2024
One more vote for re-opening the issue. We are using the template for jobs but if the pod is too big and there is no space on the runner node we get errors. This shouldn't work like that. The runner pod should be minimal and just scheduling pods with the desired resources.
jasonwbarnett commentedon Jan 26, 2025
Here is my rough plan to address this:
Update the actions-runner-controller to add a new label here to the ephemeral runner pod, i.e.
Update the runner-container-hooks to dynamically add podAffinity using the label selector matching the ephemeral runner name
With this change plus setting
ACTIONS_RUNNER_USE_KUBE_SCHEDULERtotrue, this should guarantee the the pod is spun up on the same node as the ephemeral runner pod. Even if resources aren't immediately available it would continue to try to be scheduled.Lastly, I think I can modify runner-container-hooks to pull out a nested YAML structure from jobs.<job_id>.container.options and apply it to the -workflow pod spec allowing for dynamic cpu and memory requests.
Ideally the jobs.<job_id>.container spec would be extended with a new key, but without that I could hack the existing schema and make it all work.
Any others thoughts?
velkovb commentedon Jan 26, 2025
That still seems like a workaround and there are edge cases where it might never work, i.e. the workflow pod being bigger than the node the runner is on.
Is there any possibility to work towards a different method than the PVC to share information, as those limitations stem from it?
AlexisColes commentedon Jan 26, 2025
There should definitely be some work around supporting runners working on different nodes as well. The limitation for them running on the same node is far from ideal and always going to cause some issues.
But either way the work for defining the resources in the workflow and getting that applied to the workflow container would be a great enhancement. Using the options seems a sensible way to go. 👍
What do you think @nikola-jokic ?
anlesk commentedon Sep 4, 2025
Also bumping this up with the support for re-opening.
As there is an ongoing attempt to get PVCless (#244), some of the concerns from above will not be a problem.
However, letting the workflow pod specify the resources needed for a run would add a lot of flexibility and freedom for workflows design.
So far, this can be achieved with either providing runners with pre-defined specs (populated via
$job) or by overridingACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATEwith the path to yaml file (For different templates, different files have to be present on the runner before hand, making it impossible to change it "on the fly").@nikola-jokic would that be possible to allow workflow pods to read resources and limits from the workflow file directly?
tmilnthorp commentedon Nov 5, 2026
Adding to the reopen requests above — the 0.4.0 hook-template overrides are per runner set, so they can't size an individual job. GitLab's Kubernetes executor solves exactly this, and the same shape would fit the k8s hook here:
prepare_jobfrom the job container's env, e.g.container.options: --cpus/--memory, as in Added resource requirement based on --cpus and --memory,-m #1).*_OVERWRITE_MAX_ALLOWED), so a workflow can't request more than the cluster operator allows; absent hints = template default.Use case: a self-hosted ARC pool where builds need 4–6 GiB but most jobs need <1 GiB; per-set sizes force either over-reservation or one runner set per size.