Skip to content

Log runner details at the start of each job - #135

Open
ColinKinloch wants to merge 1 commit into
collabora:mainfrom
ColinKinloch:wip/ckinloch/output_runner_header
Open

Log runner details at the start of each job#135
ColinKinloch wants to merge 1 commit into
collabora:mainfrom
ColinKinloch:wip/ckinloch/output_runner_header

Conversation

@ColinKinloch

Copy link
Copy Markdown
Contributor

This prints a header containing runner details to the gitlab log at the start of each job.

The format of the header is:

Running with demo-runner 0.3.2 (7fd27f7-dirty)
  on gitlab-runner-rs test runner XPgS3LCJG, systemd ID: s_82de14b38222

I attempted to match the string printed by the original gitlab-runner.

Fixes: collabora/lava-gitlab-runner#18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a “runner details” header to the GitLab trace output at the start of each job, aiming to match the upstream gitlab-runner header format (runner version line + “on …, systemd ID …” line).

Changes:

  • Emit a runner header at the beginning of job execution (job.output_runner_header()), including app version info and a shortened runner token.
  • Update integration/unit tests to tolerate the new header prefix and validate expected header content.
  • Add token-shortening logic (with regex) and adjust the mock runner token to include a glrt- prefix.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
gitlab-runner/src/run.rs Calls output_runner_header() at the start of each job run.
gitlab-runner/src/job.rs Implements output_runner_header() formatting and output.
gitlab-runner/src/client.rs Adds app version formatting and runner-token shortening logic.
gitlab-runner/tests/integration.rs Updates job log assertions to account for the new header.
gitlab-runner/tests/runhandler.rs Loosens log assertions to allow additional header content.
gitlab-runner/Cargo.toml Adds regex dependency.
gitlab-runner-mock/src/lib.rs Updates mock runner token prefix to match expected shortening logic.
Cargo.lock Locks regex dependency updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gitlab-runner/src/client.rs Outdated
Comment thread gitlab-runner/tests/integration.rs
Comment thread gitlab-runner/src/run.rs
@ColinKinloch
ColinKinloch force-pushed the wip/ckinloch/output_runner_header branch 2 times, most recently from 94a9bf1 to 64997a2 Compare July 31, 2026 10:10
@ColinKinloch

ColinKinloch commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Re the LLM review:

I accidentally left the .to_owned() and .as_ref() in while comparing the outputs of Regex::split and Regex::replace_all, I'm surprised clippy didn't complain.
It does compile though, In this case Option<T>::to_owned() seems to be using blanket implementation which calls .clone() on T which in this case is the blanket implementation for &T, cloning the reference. So it sidesteps the &str implementation of .to_owned().

On replacing using std::str::from_utf8 instead of str::from_utf8, the documentation says the std one is an alias to the primitive one so there's no reason to change it.

The error string was introduced in 7f8d2da and appears to be a typo from copy pasting. I've opened a separate MR for that: #136

Comment thread gitlab-runner/src/client.rs Outdated
// runner authentication token
regex!("^glrt-(t[123]_)?|^t[123]_|^glrtr-"),
// job token
regex!("^glcbt-"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this checking for a job token? Also if you could document what you're trying to do that would be nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to reproduce the behaviour of the official runner:
https://gitlab.com/gitlab-org/gitlab-runner/-/blob/654132dc91a40f80a4fd5bb290a18a13b7064aa0/helpers/shorten_token.go

I'm happy to drop everything but regex!("^glrt-(t[123]_)?|^t[123]_|^glrtr-"), but I was trying to keep to the original behaviour in case there's a good reason they wrote it that way.

@ColinKinloch ColinKinloch Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dropped everything but the ^glrt-(t[123]_)?|^t[123]_|^glrtr- checks and removed regex as a dependency in favour of chaining str::strip_prefix.

Comment thread gitlab-runner/src/client.rs Outdated
Comment thread gitlab-runner/src/client.rs Outdated
Comment thread gitlab-runner/src/job.rs Outdated
Comment thread gitlab-runner/src/job.rs Outdated
Comment thread gitlab-runner/src/client.rs Outdated
format!(
"{} {} ({})",
self.metadata
.platform

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just now realizing...are we supposed to use platform for this? The demo & lava runner do set it to the binary name, but the tests seem to use names like platform-3 which...doesn't really sound like a runner name.

This isn't necessarily load-bearing for this change, it's still a bit odd though.

Comment thread gitlab-runner/src/client.rs Outdated
@ColinKinloch
ColinKinloch force-pushed the wip/ckinloch/output_runner_header branch 2 times, most recently from c0b8020 to da08719 Compare August 3, 2026 15:48
This prints a header containing runner details to the gitlab log at the
start of each job.

The format of the header is:
```
Running with demo-runner 0.3.2 (7fd27f7-dirty)
  on gitlab-runner-rs test runner XPgS3LCJG, systemd ID: s_82de14b38222
```

I attempted to match the string printed by the original gitlab-runner.

Fixes: collabora/lava-gitlab-runner#18
@ColinKinloch
ColinKinloch force-pushed the wip/ckinloch/output_runner_header branch from da08719 to 40760ce Compare August 3, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Print the version and (partial) runner id in a banner in the log when starting a job

4 participants