Option to consider runner group visibility on scale based on webhook (#1062)

This will work on GHES but GitHub Enterprise Cloud due to excessive GitHub API calls required.
More work is needed, like adding a cache layer to the GitHub client, to make it usable on GitHub Enterprise Cloud.

Fixes additional cases from https://github.com/actions-runner-controller/actions-runner-controller/pull/1012

If GitHub auth is provided in the webhooks controller then runner groups with custom visibility are supported. Otherwise, all runner groups will be assumed to be visible to all repositories

`getScaleUpTargetWithFunction()` will check if there is an HRA available with the following flow:

1. Search for **repository** HRAs - if so it ends here
2. Get available HRAs in k8s
3. Compute visible runner groups
  a. If GitHub auth is provided - get all the runner groups that are visible to the repository of the incoming webhook using GitHub API calls.  
  b. If GitHub auth is not provided - assume all runner groups are visible to all repositories
4. Search for **default organization** runners (a.k.a runners from organization's visible default runner group) with matching labels
5. Search for **default enterprise** runners (a.k.a runners from enterprise's visible default runner group) with matching labels
6. Search for **custom organization runner groups** with matching labels
7. Search for **custom enterprise runner groups** with matching labels

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Felipe Galindo Sanchez
2022-02-16 02:08:56 -08:00
committed by GitHub
parent b509eb4388
commit d0d316252e
13 changed files with 679 additions and 156 deletions

View File

@@ -1071,6 +1071,20 @@ spec:
group: NewGroup
```
GitHub supports custom visilibity in a Runner Group to make it available to a specific set of repositories only. By default if no GitHub
authentication is included in the GitHub webhook server it will be assumed that all runner groups to be usable in all repositories.
Supporting custom visibility requires to do a few GitHub API calls to find out what are the potential runner groups that are visible to
the webhook's repository, this may incur in increased API rate limiting when using github.com
This option will be enabled when proper GitHub authentication options (token, app or basic auth is provided) in the GitHub webhook server and `useRunnerGroupsVisibility` is set to true, e.g.
```yaml
githubWebhookServer:
enabled: false
replicaCount: 1
useRunnerGroupsVisibility: true
```
### Runner Entrypoint Features
> Environment variable values must all be strings