Prevent additional newline in job in attach mode
What does this MR do?
This MR makes sure that no additional newlines are added in the job log with executorkubernetes in attach mode.
Helper adds a newline when the reader buffer doesn't end with one. Those additional newlines are not removed when streaming the log to the GitLab UI impacting the rendering of the log.
This MR makes sure that those newline are removed before the log is sent to the GitLab UI.
Why was this MR needed?
To make sure the job log is accurate and doesn't contain additional newline.
What's the best way to test this MR?
gitlab-ci
variables:
FF_USE_POWERSHELL_PATH_RESOLVER: "true"
FF_RETRIEVE_POD_WARNING_EVENTS: "true"
FF_PRINT_POD_EVENTS: "true"
FF_SCRIPT_SECTIONS: "true"
CI_DEBUG_SERVICES: "true"
GIT_DEPTH: 5
MY_TEST_VARIABLE_1: gitlab-ci
MY_TEST_VARIABLE_2: gitlab-ci
SAST_GOSEC_LEVEL: 2
END_LOOP: 50
test:
stage: test
script:
- |
for i in $(seq 1 120); do
printf .
sleep 0.02
done
config.toml
concurrent = 1
check_interval = 1
log_level = "debug"
shutdown_timeout = 0
listen_address = ':9252'
[session_server]
session_timeout = 1800
[[runners]]
name = "investigation"
url = "https://gitlab.com/"
id = 0
token = "glrt-REDACTED"
token_obtained_at = "0001-01-01T00:00:00Z"
token_expires_at = "0001-01-01T00:00:00Z"
executor = "kubernetes"
shell = "bash"
limit = 1
builds_dir = "/my_custom_dir"
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "alpine"
pod_termination_grace_period_seconds = 0
namespace = ""
namespace_overwrite_allowed = ""
pod_labels_overwrite_allowed = ""
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
node_selector_overwrite_allowed = ".*"
allow_privilege_escalation = false
[[runners.kubernetes.volumes.empty_dir]]
name = "repo"
mount_path = "/my_custom_dir"
[runners.kubernetes.build_container_security_context]
run_as_user = 1000
run_as_group = 65533
[[runners.kubernetes.services]]
[runners.kubernetes.dns_config]
[runners.kubernetes.pod_labels]
user = "ratchade"
Job passes and no additional newline in the log
Running with gitlab-runner development version (HEAD)
on investigation REDACTED, system ID: s_REDACTED
feature flags: FF_USE_POWERSHELL_PATH_RESOLVER:true, FF_SCRIPT_SECTIONS:true, FF_PRINT_POD_EVENTS:true
Preparing the "kubernetes" executor
00:00
WARNING: Namespace is empty, therefore assuming 'default'.
Using Kubernetes namespace: default
Using Kubernetes executor with image alpine ...
Using attach strategy to execute scripts...
Preparing environment
00:04
Using FF_USE_POD_ACTIVE_DEADLINE_SECONDS, the Pod activeDeadlineSeconds will be set to the job timeout: 30m0s...
Subscribing to Kubernetes Pod events...
Type Reason Message
Normal Scheduled Successfully assigned default/runner-REDACTED-project-25452826-concurrent-0-x3nczs0a to minikube
Normal Pulled Container image "registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-latest" already present on machine
Normal Created Created container init-permissions
Normal Started Started container init-permissions
Normal Pulling Pulling image "alpine"
Normal Pulled Successfully pulled image "alpine" in 324ms (324ms including waiting). Image size: 4090801 bytes.
Normal Created Created container build
Normal Started Started container build
Normal Pulled Container image "registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-latest" already present on machine
Normal Created Created container helper
Normal Started Started container helper
Running on runner-REDACTED-project-25452826-concurrent-0-x3nczs0a via ratchade-MBP...
Getting source from Git repository
00:02
Fetching changes with git depth set to 5...
Initialized empty Git repository in /my_custom_dir/ra-group2/playground-bis/.git/
Created fresh repository.
Checking out f5d9fae3 as detached HEAD (ref is master)...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:03
$ for i in $(seq 1 120); do
printf .
sleep 0.02
done
........................................................................................................................
Cleaning up project directory and file based variables
00:00
Job succeeded
What are the relevant issue numbers?
close #27099 (closed)
Edited by Romuald Atchadé