actions-runner-controller: Listener gets into crash loop with createSession 409 error
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 name
Describe 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:
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
-
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 15 (3 by maintainers)
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.
https://github.com/actions/actions-runner-controller/blob/47dfed3ced786c117a58cbacedd8b5fb90777882/cmd/githubrunnerscalesetlistener/autoScalerService.go#L242-L245
For v0.8.0 (ghalistener), it returns the error and the listener process accidentally exits.
https://github.com/actions/actions-runner-controller/blob/47dfed3ced786c117a58cbacedd8b5fb90777882/cmd/ghalistener/listener/listener.go#L182-L184
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.
https://github.com/actions/actions-runner-controller/blob/202a97ab12833b4916ad7312b1cf235e4b802f0c/cmd/githubrunnerscalesetlistener/main.go#L191 https://github.com/actions/actions-runner-controller/blob/336e11a4e92d3086e756d344713f34aaac339512/cmd/githubrunnerscalesetlistener/autoScalerMessageListener.go#L127-L130 https://github.com/actions/actions-runner-controller/blob/47dfed3ced786c117a58cbacedd8b5fb90777882/cmd/githubrunnerscalesetlistener/sessionrefreshingclient.go#L116
For v0.8.0 (ghalistener), it does not delete the session. I think it causes 409 errors.
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!
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.
@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.https://github.com/actions/actions-runner-controller/blob/47dfed3ced786c117a58cbacedd8b5fb90777882/controllers/actions.github.com/resourcebuilder.go#L237
You can do it by updating the listener template: https://github.com/actions/actions-runner-controller/blob/47dfed3ced786c117a58cbacedd8b5fb90777882/charts/gha-runner-scale-set-controller/values.yaml#L21
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.
Hi @nikola-jokic,
Ok, I’ll see if I can reproduce this error again.
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 😞
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: https://github.com/actions/actions-runner-controller/blob/5f23afaad311be44be1781b09541d0a01d7912a3/main.go#L206/ghalistener: https://github.com/actions/actions-runner-controller/blob/5f23afaad311be44be1781b09541d0a01d7912a3/controllers/actions.github.com/resourcebuilder.go#L44@Link- Awesome! I missed that. Thank you for sharing and all your effort!