When using custom container hooks in self-hosted runners, docker args is not passed correctly
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
- Use the base build of runner-container-hooks when using
github-runner-scale-seton k8s to have self-hosted runners. - 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
-
run the action, and it will show how the multiline argument has been converted into a single line, respecting only
/n/nnot\not\tor trailing spaces -
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 - Please provide any other information that will help. We have an internal Issue pointing here for reproduction steps or any other additional information you can provide. Thank you.
@EttoreFoti - Please provide any other information that will help. We have an internal Issue pointing here for reproduction steps or any other additional information you can provide. Thank you.
Hi! The issue can be replicated by using the latest version of gha-runner-scale-set and enabling the docker custom hooks from runner-container-hooks. In this way you will see how it behaves different when the hooks are enabled compared to the default behavior, and it breaks multiline formatting as written in the main issue.