Resolve "get "panic: EOF" when register runners run in a container"
What does this MR do?
This MR wraps io.EOF
errors in the askOnce
function, to avoid the panic
condition down the line.
It provides an error message with a suggestion on how to avoid this.
Why was this MR needed?
To prevent a panic
condition with a known fix.
What's the best way to test this MR?
Running the register
command in a Docker container, without allocating an interactive terminal, and omitting the --non-interactive
-flag:
podman run --rm gitlab/gitlab-runner:alpine register --url https://gitlab.com --token glrt-derpfooba
docker run --rm gitlab/gitlab-runner:alpine register --url https://gitlab.com --token glrt-derpfooba
Pass / Fail output
Pass
❯ docker run --rm gitlab/gitlab-runner:alpine register --url https://gitlab.com --token glrt-derpfooba
Runtime platform arch=arm64 os=linux pid=1 revision=582bd361 version=17.4.0~pre.152.g582bd361
Running in system-mode.
Created missing unique system ID system_id=r_JoVraPIpx3IV
Enter the GitLab instance URL (for example, https://gitlab.com/):
[https://gitlab.com]: PANIC: Unexpected EOF. Did you mean to use --non-interactive?
Fail
❯ docker run --rm gitlab/gitlab-runner:alpine register --url https://gitlab.com --token glrt-derpfooba
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Runtime platform arch=arm64 os=linux pid=2 revision=66269445 version=17.3.1
Running in system-mode.
Created missing unique system ID system_id=r_kXTNV8xZBil3
Enter the GitLab instance URL (for example, https://gitlab.com/):
[https://gitlab.com]: panic: EOF [recovered]
panic: EOF
goroutine 1 [running]:
main.main.func1()
/builds/gitlab-org/gitlab-runner/main.go:52 +0x60
panic({0x1baf960?, 0x37af010?})
/usr/local/go/src/runtime/panic.go:770 +0x124
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).askOnce(0x4000175508, {0x2094a06, 0x41}, 0x400128f278, 0x0)
/builds/gitlab-org/gitlab-runner/commands/register.go:120 +0x230
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).ask(0x4000175508, {0x1ff20ce, 0x3}, {0x2094a06, 0x41}, {0x0?, 0x4001217620?, 0x24?})
/builds/gitlab-org/gitlab-runner/commands/register.go:150 +0x12c
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).askRunner(0x4000175508)
/builds/gitlab-org/gitlab-runner/commands/register.go:263 +0x4c
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).Execute(0x4000175508, 0x40008ed340)
/builds/gitlab-org/gitlab-runner/commands/register.go:432 +0x170
github.com/urfave/cli.HandleAction({0x1aab8c0?, 0x4001312000?}, 0x8?)
/go/pkg/mod/github.com/urfave/cli@v1.22.14/app.go:526 +0x94
github.com/urfave/cli.Command.Run({{0x1ffa952, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x201aea6, 0x15}, {0x0, ...}, ...}, ...)
/go/pkg/mod/github.com/urfave/cli@v1.22.14/command.go:175 +0x534
github.com/urfave/cli.(*App).Run(0x4001302a80, {0x400004c2a0, 0x6, 0x6})
/go/pkg/mod/github.com/urfave/cli@v1.22.14/app.go:277 +0x7f8
main.main()
/builds/gitlab-org/gitlab-runner/main.go:82 +0x63
What are the relevant issue numbers?
Edited by Niklas Janz