From f74dfc1ab54096bea7a1fe86b2a1ac9c5f145ec8 Mon Sep 17 00:00:00 2001 From: Rickard Granberg Date: Sat, 8 Jun 2024 13:11:07 +0000 Subject: [PATCH] Implement filter that handles conclusions other than 'success' --- .../horizontal_runner_autoscaler_webhook.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/actions.summerwind.net/horizontal_runner_autoscaler_webhook.go b/controllers/actions.summerwind.net/horizontal_runner_autoscaler_webhook.go index 85c4bc48..f341083b 100644 --- a/controllers/actions.summerwind.net/horizontal_runner_autoscaler_webhook.go +++ b/controllers/actions.summerwind.net/horizontal_runner_autoscaler_webhook.go @@ -217,7 +217,8 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) Handle(w http.Respons // But canceled events have runner_id == 0 and GetRunnerID() returns 0 when RunnerID == nil, // so we need to be more specific in filtering out the check runs. // See example check run completion at https://gist.github.com/nathanklick/268fea6496a4d7b14cecb2999747ef84 - if e.GetWorkflowJob().GetConclusion() == "success" && e.GetWorkflowJob().RunnerID == nil { + // Check runs appear to have no labels set, so use that in conjuction with the nil RunnerID to filter the event: + if len(e.GetWorkflowJob().Labels) == 0 && e.GetWorkflowJob().RunnerID == nil { log.V(1).Info("Ignoring workflow_job event because it does not relate to a self-hosted runner") } else { // A negative amount is processed in the tryScale func as a scale-down request,