actions-runner-controller: Listener gets into crash loop with createSession 409 error

Checks

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:

https://github.com/actions/actions-runner-controller/blob/f7eb88ce9c6b3cf013ae825bef197773e2bc9d0b/cmd/ghalistener/worker/worker.go#L144

https://github.com/actions/actions-runner-controller/blob/b78cadd90105030e122f78758ba7c3c283a931ab/cmd/ghalistener/listener/listener.go#L181-L185

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)

Most upvoted comments

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!

Update the LISTENER_ENTRYPOINT to github-runnerscaleset-listener in order to use older listener app.

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_ENTRYPOINT to /github-runnerscaleset-listener in 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_ENTRYPOINT with a value of github-runnerscaleset-listener in 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 the command didn’t update for the listener pod. Here was a section of my values file for the gha-runner-scale-set helm chart:

listenerTemplate:
  spec:
    containers:
      - name: listener
        securityContext:
          runAsUser: 1000
        env:
          - name: LISTENER_ENTRYPOINT
            value: github-runnerscaleset-listener

Here is the kubectl pod describe:

Containers:
  listener:
    Container ID:
    Image:         ghcr.io/actions/gha-runner-scale-set-controller:0.8.1
    Image ID:
    Port:          8080/TCP
    Host Port:     0/TCP
    Command:
      /ghalistener
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:
      LISTENER_CONFIG_PATH:  /etc/gha-listener/config.json
      LISTENER_ENTRYPOINT:   github-runnerscaleset-listener

Notice here that the Command: /ghalistener is 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_ENTRYPOINT with the value of /github-runnerscaleset-listener to the values file for the gha-runner-scale-set-controller helm chart. Here is an example:

replicaCount: 1
labels: {}

env: 
  - name: LISTENER_ENTRYPOINT
    value: /github-runnerscaleset-listener

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 pod on the listener:

Containers:
  listener:
    Container ID:  containerd://c0baad31de660705d8abf992aaf3aae2357531e247a0e679dbe268b666136bc8
    Image:         ghcr.io/actions/gha-runner-scale-set-controller:0.8.1
    Image ID:      ghcr.io/actions/gha-runner-scale-set-controller@sha256:14f6df6f6300f34c4377b05e72378b05d813160556e3fd3415e56049d7b30ac2
    Port:          8080/TCP
    Host Port:     0/TCP
    Command:
      /github-runnerscaleset-listener
    State:          Running
      Started:      Wed, 24 Jan 2024 18:46:21 -0600
    Ready:          True
    Restart Count:  0
    Environment:
      LISTENER_CONFIG_PATH:  /etc/gha-listener/config.json

Here’s the code path I followed to get to this solution:

@Link- Awesome! I missed that. Thank you for sharing and all your effort!