Repository navigation
Closed
Labels
bugSomething isn't workinggha-runner-scale-setRelated to the gha-runner-scale-set modepriority-0Lower numbers eq. higher priority
Description
Checks
- I've already read https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller/troubleshooting-actions-runner-controller-errors and I'm sure my issue is not covered in the troubleshooting guide.
- I am using charts that are officially provided
Controller Version
0.8.1
Deployment Method
ArgoCD
Checks
- This isn't a question or user support case (For Q&A and community support, go to Discussions).
- I've read the Changelog before submitting this issue and I'm sure it's not due to any recently-introduced backward-incompatible changes
To Reproduce
We have 2 Kubernetes clusters.
1. Install the controller into `arc-systems` namespace of cluster A
2. Install the controller into `arc-systems` namespace of cluster B
3. Add a gha-runner-scale-set into `arc-runners` namespace of cluster A. The runner belongs to a repository
4. Add a gha-runner-scale-set into `arc-runners` namespace of cluster B. The runner belongs to the same repository, but has the different runner nameDescribe the bug
A listener pod suddenly exits with the following error:
example-754b578d-listener listener 2024-01-09T06:12:25Z INFO listener-app.worker.kubernetesworker Updating job info for the runner {"runnerName": "example-6hcw5-runner-fb29k", REDACTED, "requestId": 6421142}
example-754b578d-listener listener 2024-01-09T06:12:25Z INFO listener-app.worker.kubernetesworker Updating ephemeral runner with merge patch {"json": "{\"status\":{\"jobDisplayName\":\"REDACTED\",\"workflowRunId\":7457087460}}"}
example-754b578d-listener listener 2024/01/09 06:12:25 Application returned an error: failed to handle job started: could not patch ephemeral runner status, patch JSON: {"status":{"jobDisplayName":"REDACTED","workflowRunId":7457087460}}, error: ephemeralrunners.actions.github.com "example-6hcw5-runner-fb29k" not found
After that, the listener pod gets into a crash loop with the following error:
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app app initialized
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app Starting metrics server
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app Starting listener
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app refreshing token {"githubConfigUrl": "https://github.com/REDACTED"}
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app getting access token for GitHub App auth {"accessTokenURL": "https://api.github.com/app/installations/REDACTED/access_tokens"}
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app getting runner registration token {"registrationTokenURL": "https://api.github.com/repos/REDACTED/actions/runners/registration-token"}
example-754b578d-listener listener 2024-01-09T06:12:27Z INFO listener-app getting Actions tenant URL and JWT {"registrationURL": "https://api.github.com/actions/runner-registration"}
example-754b578d-listener listener 2024/01/09 06:12:28 Application returned an error: createSession failed: failed to create session: 409 - had issue communicating with Actions backend: The runner scale set example already has an active session for owner example-754b578d-listener.
It seems the listener exits at:
| return fmt.Errorf("could not patch ephemeral runner status, patch JSON: %s, error: %w", string(mergePatch), err) |
actions-runner-controller/cmd/ghalistener/listener/listener.go
Lines 181 to 185 in b78cadd
| for _, jobStarted := range jobsStarted { | |
| if err := handler.HandleJobStarted(ctx, jobStarted); err != nil { | |
| return fmt.Errorf("failed to handle job started: %w", err) | |
| } | |
| } |
Describe the expected behavior
It would be nice to keep a listener running even if a merge patch is failed.
Additional Context
-Controller Logs
2024-01-09T06:04:04Z INFO EphemeralRunner Checking if runner exists in GitHub service {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}, "runnerId": 6247604}
2024-01-09T06:04:04Z INFO EphemeralRunner Runner does not exist in GitHub service {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}, "runnerId": 6247604}
2024-01-09T06:04:04Z INFO EphemeralRunner Ephemeral runner has finished since it does not exist in the service anymore {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Updating ephemeral runner status to Finished {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner EphemeralRunner status is marked as Finished {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner EphemeralRunner has already finished. Stopping reconciliation and waiting for EphemeralRunnerSet to clean it up {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}, "phase": "Succeeded"}
2024-01-09T06:04:04Z INFO EphemeralRunnerSet Deleting finished ephemeral runner {"ephemeralrunnerset": {"name":"example-6hcw5","namespace":"arc-runners"}, "name": "example-6hcw5-runner-fb29k"}
2024-01-09T06:04:04Z INFO EphemeralRunner Successfully removed runner registration finalizer {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Finalizing ephemeral runner {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Cleaning up the runner pod {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Deleting the runner pod {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Waiting for ephemeral runner owned resources to be deleted {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Finalizing ephemeral runner {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Cleaning up the runner pod {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:04:04Z INFO EphemeralRunner Waiting for ephemeral runner owned resources to be deleted {"ephemeralrunner": {"name":"example-6hcw5-runner-fb29k","namespace":"arc-runners"}}
2024-01-09T06:12:26Z INFO AutoscalingListener Listener pod failed, deleting it and re-creating it {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener", "reason": "", "message": ""}"
2024-01-09T06:12:26Z INFO AutoscalingListener Creating a listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}}"
2024-01-09T06:12:26Z INFO AutoscalingListener Creating listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener"}"
2024-01-09T06:12:26Z INFO AutoscalingListener Created listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener"}"
2024-01-09T06:12:30Z INFO AutoscalingListener Listener pod failed, deleting it and re-creating it {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener", "reason": "", "message": ""}"
2024-01-09T06:12:30Z INFO AutoscalingListener Creating a listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}}"
2024-01-09T06:12:30Z INFO AutoscalingListener Creating listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener"}"
2024-01-09T06:12:30Z INFO AutoscalingListener Created listener pod {"autoscalinglistener": {"name":"example-754b578d-listener","namespace":"arc-systems"}, "namespace": "arc-systems", "name": "example-754b578d-listener"}"Runner Pod Logs
-Reacted by kyontan, barribarrier, Tiago Martins, Lucas Prado, Alex Hatzenbuhler, panicboat, Yusuke Kuoka, synack-badamson, Maxime Sibellas, Nicholas Hawkes and 3 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggha-runner-scale-setRelated to the gha-runner-scale-set modepriority-0Lower numbers eq. higher priority
Activity
[-]<Please write what didn't work for you here>[/-][+]Listener gets into crash loop with createSession 409 error[/+]int128 commentedon Jan 16, 2024
I have reverted the Helm chart to v0.7.0 and then the self-hosted runners seems stable.
I noticed the below differences between v0.7.0 (githubrunnerscalesetlistener) and v0.8.0 (ghalistener). Could you check them?
Error handling on updating an EphemeralRunner
For v0.7.0 (githubrunnerscalesetlistener), it just writes an error log.
actions-runner-controller/cmd/githubrunnerscalesetlistener/autoScalerService.go
Lines 242 to 245 in 47dfed3
For v0.8.0 (ghalistener), it returns the error and the listener process accidentally exits.
actions-runner-controller/cmd/ghalistener/listener/listener.go
Lines 182 to 184 in 47dfed3
I think it should handle the error to avoid crash loop.
Graceful shutdown of Actions service session
For v0.7.0 (githubrunnerscalesetlistener), it deletes the current session.
actions-runner-controller/cmd/githubrunnerscalesetlistener/main.go
Line 191 in 202a97a
actions-runner-controller/cmd/githubrunnerscalesetlistener/autoScalerMessageListener.go
Lines 127 to 130 in 336e11a
actions-runner-controller/cmd/githubrunnerscalesetlistener/sessionrefreshingclient.go
Line 116 in 47dfed3
For v0.8.0 (ghalistener), it does not delete the session. I think it causes 409 errors.
mumoshu commentedon Jan 16, 2024
@nikola-jokic @Link- Hey! I think we found some regression in 0.8.0.
I discussed offline with @int128, and I believe this is caused by the eventual consistency of data returned by GHA, which was handled gracefully in 0.7.0 but not in 0.8.0.
Our theory:
We think the new ghalistener introduced in 0.8.0 has two regressions(would you mind confirming?) related to step 8, where:
deferlikeactions-runner-controller/cmd/githubrunnerscalesetlistener/main.go
Lines 186 to 191 in 47dfed3
actions-runner-controller/cmd/ghalistener/app/app.go
Lines 107 to 133 in 47dfed3
actions-runner-controller/cmd/githubrunnerscalesetlistener/autoScalerService.go
Line 244 in 47dfed3
actions-runner-controller/cmd/ghalistener/listener/listener.go
Lines 182 to 184 in 47dfed3
@nikola-jokic @Link- If the above theory stands, can we at least fix the second bullet point so that the listener doesn't start failing immediately when the GHA service returns stale data?
From @int128 and his colleagues' observation, the
runner scale set example already has an active session for owner example-754b578d-listenererror seems to persist for approx 10 minutes which delays the job runs for the runnerscaleset for that long, and this seems to happen quite often 🤔Link- commentedon Jan 16, 2024
@mumoshu @int128 thank you for your great work troubleshooting and reporting this issue. We will address it in a patch release, in the meantime, you don't have to revert to previous versions. We expected some problems to arise with the new listener so we included a fallback:
Update the
LISTENER_ENTRYPOINTto/github-runnerscaleset-listenerin order to use older listener app.actions-runner-controller/controllers/actions.github.com/resourcebuilder.go
Line 237 in 47dfed3
You can do it by updating the listener template:
actions-runner-controller/charts/gha-runner-scale-set-controller/values.yaml
Line 21 in 47dfed3
mumoshu commentedon Jan 16, 2024
@Link- Awesome! I missed that. Thank you for sharing and all your effort!
TiagoJMartins commentedon Jan 18, 2024
This definitely fixed it for me on 0.8.1, mentioned here. Hoping the next release will include the permanent fix 🤞🏻
I was also having issues with high-usage runner sets getting into this crashing state, and that has also been resolved by changing the entrypoint.
ahatzz11 commentedon Jan 25, 2024
I hit this issue in our organization today and had a very hard time fixing it with the above suggestions, so I'm putting some information here to help others that might run into this until a proper fix is in place. We are running ~50 runners at max right now and have hundreds to thousands of individual jobs a day. If anything here below is wrong please let me know.
Above @Link- mentioned that you should insert
LISTENER_ENTRYPOINTwith a value ofgithub-runnerscaleset-listenerin the listener template. I think there might be some confusion here because it seems this is the incorrect value to use and the incorrect location to put this env var. After attempting the proposed fix above I still encountered this patch issue and I noticed that thecommanddidn't update for the listener pod. Here was a section of my values file for thegha-runner-scale-sethelm chart:Here is the
kubectl pod describe:Notice here that the
Command: /ghalisteneris still pointing at the new listener. This solution from above does not seem to work.The solution I found to work here is to add an env var of
LISTENER_ENTRYPOINTwith the value of/github-runnerscaleset-listenerto the values file for the gha-runner-scale-set-controller helm chart. Here is an example:This changes the environment variable on the controller which then creates a listener that has the proper entrypoint. This can be seen with another
kubectl describe podon the listener:Here's the code path I followed to get to this solution:
main.gofor the controller is what reads theLISTENER_ENTRYPOINTenv var:actions-runner-controller/main.go
Line 206 in 5f23afa
actions-runner-controller/controllers/actions.github.com/resourcebuilder.go
Line 65 in 5f23afa
/ghalistener:actions-runner-controller/controllers/actions.github.com/resourcebuilder.go
Line 44 in 5f23afa
Link- commentedon Jan 25, 2024
Sorry about that @ahatzz11 - you are right, I missed the
/in my comment. I've edited it now to fix it. We're pushing a fix for this soon, stay tuned.ahatzz11 commentedon Jan 25, 2024
@Link- Thanks for the update! I still think the original comment is incorrect though. It says to put it in the
listenerTemplate:section of the values file for thegha-runner-scale-setchat, but it should actually live at the root level of the values file for thegha-runner-scale-set-controllerchart.Super excited to see some fixes for these issues! Happy to do some testing in our environment when it is all ready to go.
y-takebe commentedon Mar 12, 2024
Hi, there.
I encountered a similar problem when using ARC at the Organization level, a restart loop for AutoscalingListener.
The solution described by @ahatzz11, setting env in the helm chart of gha-runner-scale-set-controller, solved the restart loop.
I spent 10 days to get to this page! 😵
I think it should be in the official GitHub documentation or after adding the env setting to the chart to resolve it.
Thanks!
softlberton commentedon Apr 16, 2024
I've been working with ARC for the last two days, yesterday I was able to install ARC without any problems using GitHub App authentication and it works fine.
Today I'm doing the same, installing ARC using PAT authentication and I got this error:
2024-04-16T08:29:55Z INFO listener-app getting Actions tenant URL and JWT {"registrationURL": "https://api.github.com/actions/runner-registration"} 2024/04/16 08:29:55 Application returned an error: createSession failed: failed to create session: 409 - had issue communicating with Actions backend: The runner scale set arc-runner-set already has an active session for owner arc-runner-set-754b578d-listener.Thanks @ahatzz11 for indicating the solution (workaround) for this problem, so I managed to solve this problem by installing arc-runner-set as follows:
ARC runner type: GitHub Org
ARC runner version: 0.9.0
nikola-jokic commentedon Apr 16, 2024
Hey @softlberton,
Can you please help me by writing down how to reproduce this problem? I'm struggling to replicate it and I would really like to get to the bottom of it, but I'm failing to reproduce it 😞
softlberton commentedon Apr 16, 2024
Hi @nikola-jokic,
Ok, I'll see if I can reproduce this error again.
joekhoobyar commentedon Jul 1, 2024
This is still happening for me.
casey-robertson-paypal commentedon Aug 28, 2024
Perhaps there is another failure mode or regression? We have only ever been on 0.8.3 of the controller chart and we are experiencing this with one of our listeners right now.
luis02lopez commentedon Nov 28, 2024
Ok, finally I got it working, thanks to @ahatzz11 for noticing that the change must be in the set-controller, not the set. I deploy my charts with Terraform.
Important: After making the change, you'll need to uninstall/remove the charts and install it again, if not, the fail loop is still going to happen but every 10 minutes, full solution: