Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using custom container hooks in self-hosted runners, docker args is not passed correctly #3598

Open
EttoreFoti opened this issue Nov 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@EttoreFoti
Copy link

EttoreFoti commented Nov 28, 2024

Describe the bug
When using custom container hooks, using a docker step with multiline args is being forwarded with the wrong formatting, it's removing newlines (/n) and tabs/indent (/t) or any sort of trailing space.

To Reproduce

  1. Use the base build of runner-container-hooks when using github-runner-scale-set on k8s to have self-hosted runners.
  2. Run a workflow like the following:
runs:
  using: "docker"
  image: "ubuntu:latest"
  entrypoint: "/bin/bash"
  args:
    - "-c"
    - |
      cd /github/workspace

      if [[ ! -z true ]]; then
        package_overrides="a b c"
        for package_override in $package_overrides; do
          echo "package_override: $package_override"
        done
      fi

      exit $exit_code
  1. run the action, and it will show how the multiline argument has been converted into a single line, respecting only /n/n not \n ot \t or trailing spaces

  2. by adding logs to runner-container-hooks, we prove that the input being sent to the container has been converted to a list of strings and has already trimmed newlines, tabs and spaces

"entryPointArgs":["\"-c\"","\"cd","/github/workspace\n\nif","[[","!","-z","true","]];","then","echo","\\\"abdcs\\\"\nfi\n\nif","[[","!","-z","false","]];","then","echo","\\\"false\\\"\nfi\n\nif","[[","!","-z","true","]];","then","test=\\\"a","b","c\\\"","for","package_override","in","$package_overrides;","do","echo","\\\"package_override:","$package_override\\\"","done\nfi\n\nexit","$exit_code\""],

Expected behavior
The hook should receive the text with the right format, not a splitted list of strings that loses spaces/newlines on merging it back.

It looks like this handler line could be causing the issue:

EntryPointArgs = container.ContainerEntryPointArgs?.Split(' ').Select(arg => arg.Trim()).Where(arg => !string.IsNullOrEmpty(arg)) ?? new List<string>();

Runner Version and Platform

2.321.0

OS of the machine running the runner?
Linux

What's not working?

Hook input not correctly shipped.

Job Log Output

Not applicable

Runner and Worker's Diagnostic Logs

Not applicable

@EttoreFoti EttoreFoti added the bug Something isn't working label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant