Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#951): add exception for self-hosted label in webhook search #953

Merged
merged 1 commit into from Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ spec:
duration: "30m"
```

This webhook requires you to explicitely set the labels in the RunnerDeployment / RunnerSet if you are using them in your workflow to match the agents (field `runs-on`). Only `self-hosted` will be considered as included by default.

You can configure your GitHub webhook settings to only include `Workflows Job` events, so that it sends us three kinds of `workflow_job` events per a job run.

Each kind has a `status` of `queued`, `in_progress` and `completed`. With the above configuration, `actions-runner-controller` adds one runner for a `workflow_job` event whose `status` is `queued`. Similarly, it removes one runner for a `workflow_job` event whose `status` is `completed`. The cavaet to this to remember is that this the scale down is within the bounds of your `scaleDownDelaySecondsAfterScaleOut` configuration, if this time hasn't past the scale down will be defered.
Expand Down
24 changes: 16 additions & 8 deletions controllers/horizontal_runner_autoscaler_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,17 @@ HRA:
return nil, err
}

if len(labels) == 1 && labels[0] == "self-hosted" {
return &ScaleTarget{HorizontalRunnerAutoscaler: hra, ScaleUpTrigger: v1alpha1.ScaleUpTrigger{Duration: duration}}, nil
}

// Ensure that the RunnerSet-managed runners have all the labels requested by the workflow_job.
for _, l := range labels {
var matched bool

// ignore "self-hosted" label as all instance here are self-hosted
if l == "self-hosted" {
continue
}

// TODO labels related to OS and architecture needs to be explicitely declared or the current implementation will not be able to find them.

for _, l2 := range rs.Spec.Labels {
if l == l2 {
matched = true
Expand All @@ -607,13 +611,17 @@ HRA:
return nil, err
}

if len(labels) == 1 && labels[0] == "self-hosted" {
return &ScaleTarget{HorizontalRunnerAutoscaler: hra, ScaleUpTrigger: v1alpha1.ScaleUpTrigger{Duration: duration}}, nil
}

// Ensure that the RunnerDeployment-managed runners have all the labels requested by the workflow_job.
for _, l := range labels {
var matched bool

// ignore "self-hosted" label as all instance here are self-hosted
if l == "self-hosted" {
continue
}

// TODO labels related to OS and architecture needs to be explicitely declared or the current implementation will not be able to find them.

for _, l2 := range rd.Spec.Template.Spec.Labels {
if l == l2 {
matched = true
Expand Down