actions / runner-container-hooks

Runner Container Hooks for GitHub Actions
MIT License
63 stars 41 forks source link

Arguments to `docker` step double quoted in kubernetes containerMode #133

Closed kwohlfahrt closed 5 months ago

kwohlfahrt commented 5 months ago

Checks

Controller Version

0.8.1

Deployment Method

Helm

Checks

To Reproduce

1. Deploy `gha-runner-scale-set` chart with `containerMode.type: kubernetes`
2. Run a workflow containing a `docker` action as a step. In our case, it was https://github.com/irongut/CodeCoverageSummary
3. `kubectl get --watch -o yaml` the worker containers, until you see the container spawned for this step

Describe the bug

The arguments of the container for the docker step are quoted incorrectly:

  - args:
    - '"--files"'
    - '"././coverage.xml"'
    ... # Other args similar
    - '"80'
    - 100"

Note both that the --files option is double-quoted, and the final option "80 100" seems to be incorrectly split. The original argument definition is here in the action.

This causes the container to error with Required option 'files' is missing. (see logs below), because the argument is passed as "--files", not --files.

Describe the expected behavior

I expect the args to be passed correctly as strings, specifically all arguments apart from the last two should have one less level of quoting, and the last two arguments should either be two arguments, or be a single string 80 100.

This action worked correctly on the summerwind runner.

Additional Context

For the actions runner system:

serviceAccount:
  create: false
  name: actions-runner-system-9ed664d1

For the actions runner itself:

containerMode:
  kubernetesModeWorkVolumeClaim:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 1Gi
    storageClassName: exclusive
  type: kubernetes
controllerServiceAccount:
  name: actions-runner-system-9ed664d1
  namespace: actions-runner-system-d70d5c4f
githubConfigSecret: actions-runner-4ec61cf4
githubConfigUrl: https://github.com/CHARM-Tx
maxRunners: 5
minRunners: 1
template:
  spec:
    containers:
    - command:
      - /home/runner/run.sh
      env:
      - name: ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER
        value: "false"
      # Image was from a private registry, but largely the public image plus a very small number of extra `apt` packages installed.
      image: <snip>
      name: runner
      resources:
        limits:
          cpu: "1"
    securityContext:
      fsGroup: 1001

Controller Logs

https://gist.github.com/kwohlfahrt/e529299aae54fd4a176d41ec2cc3255c#file-controller-log

Runner Pod Logs

runner pod: https://gist.github.com/kwohlfahrt/e529299aae54fd4a176d41ec2cc3255c#file-runner-log
step pod: https://gist.github.com/kwohlfahrt/e529299aae54fd4a176d41ec2cc3255c#file-step-log
step pod definition: https://gist.github.com/kwohlfahrt/e529299aae54fd4a176d41ec2cc3255c#file-step-yaml
github-actions[bot] commented 5 months ago

Hello! Thank you for filing an issue.

The maintainers will triage your issue shortly.

In the meantime, please take a look at the troubleshooting guide for bug reports.

If this is a feature request, please review our contribution guidelines.

nikola-jokic commented 5 months ago

Hey @kwohlfahrt,

What version of the hook are you using inside the image?

kwohlfahrt commented 5 months ago

Our image is based off of ghcr.io/actions/actions-runner:2.312.0, which is confirmed in the runner logs:

[RUNNER 2024-02-08 14:43:04Z INFO Listener] Runner is built for Linux (X64) - linux-x64.
[RUNNER 2024-02-08 14:43:04Z INFO Listener] RuntimeInformation: Linux 5.15.0-1052-aws actions/actions-runner-controller#57-Ubuntu SMP Mon Jan 15 15:24:00 UTC 2024.
[RUNNER 2024-02-08 14:43:04Z INFO Listener] Version: 2.312.0
[RUNNER 2024-02-08 14:43:04Z INFO Listener] Commit: 1615de2f78ce16935be95ace79d35ed22b0837be

Is this what you mean by the version of the hook? Or is that specified elsewhere?

nikola-jokic commented 5 months ago

Can you please try using the 2.313.0 version? The version of the hook included in the 2.313.0 version is 0.5.1, which should have arguments fixed.

Otherwise, since it is based on your image, could you please change the hook version in your dockerfile to 0.5.1 and let us know if the issue persists?

I will transfer this issue to the hook repo, since ARC is not in charge of arguments passed to the container hook. Please let us know if the issue is resolved with the new hook version :relaxed:

kwohlfahrt commented 5 months ago

I've rebuilt our image on top of 2.313.0, and it now seems to work as expected - the image step in question succeeds, and all of the quoting looks correct with kubectl get pods -o yaml.

Thank you!