Job gets stuck with attach strategy when the last command does not return a newline
So I am trying out the new kubernetes attach strategy by setting with FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY=false
and ran into an issue with a script that does not return a newline after the last command.
The issue is really simple to reproduce:
stages:
- newline-bug
newline-bug:
stage: newline-bug
image: busybox
script:
- echo -n "things are breaking"
variables:
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: false
This results in the following job output:
Running with gitlab-runner 12.9.0 (4c96e5ad)
on gitlab-runner-544d7fd698-vd64x XGYv2B13
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: nine-gitlab-runner
Using Kubernetes executor with image busybox ...
Using attach strategy to execute scripts...
Preparing environment
Waiting for pod nine-gitlab-runner/runner-xgyv2b13-project-1104-concurrent-0f84sc to be running, status is Pending
Waiting for pod nine-gitlab-runner/runner-xgyv2b13-project-1104-concurrent-0f84sc to be running, status is Pending
Running on runner-xgyv2b13-project-1104-concurrent-0f84sc via gitlab-runner-544d7fd698-vd64x...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/gcp/testing/runner-newline-bug/.git/
Created fresh repository.
From https://gitlab.nine.ch/gcp/testing/runner-newline-bug
* [new ref] refs/pipelines/82740 -> refs/pipelines/82740
* [new branch] master -> origin/master
Checking out 151d796e as master...
Skipping Git submodules setup
Restoring cache
00:00
Downloading artifacts
00:00
Running before_script and script
$ echo -n "things are breaking"
things are breaking{"command_exit_code": 0, "script": "/builds/gcp/testing/runner-newline-bug.tmp/scripts/build_script"}
The job will never complete as the runner does not parse the log line with the runner_script_trap
.
Runner version: v12.9.0
Kubernetes Version: v1.14.10-gke.27
I guess one fix for this would be to always write a newline before writing the runner_script_trap
here.