Allow LAVA jobs to pass artifacts back to the runner - #132
Conversation
- Add axum = "0.8" dependency; enable full tokio features
- New src/upload.rs: UploadServer, UploadStore, JobArtifacts (RAII-based,
auto-deregisters on drop, no global static, no periodic cleanup)
- Add runner.ARTIFACT_UPLOAD_URL template variable via TransformVariables.runner
- Add Artifact{path, data} to LavaUploadableFileType (path only, no id prefix)
- Run struct gains upload_server and artifacts fields
- transform() takes upload_url param; submit command creates JobArtifacts
- get_uploadable_files() includes artifacts from submit jobs
- upload_artifact axum handler uses State<Arc<Mutex<UploadStore>>>
- main() starts server only if LAVA_ARTIFACT_UPLOAD_BASE_URL is set
- Single env var replaces separate host/port; uses TcpListener::bind + axum::serve
Agent-Logs-Url: https://github.com/collabora/lava-gitlab-runner/sessions/831d8c7f-5dc6-47d2-82c1-7e79eed0c6bf
Co-authored-by: sjoerdsimons <[email protected]>
Agent-Logs-Url: https://github.com/collabora/lava-gitlab-runner/sessions/c13029b6-3fd3-44cc-ac99-b9bf964efe56 Co-authored-by: sjoerdsimons <[email protected]>
…HTTP status codes Agent-Logs-Url: https://github.com/collabora/lava-gitlab-runner/sessions/439b5174-50be-4263-8ccd-e88b204f9251 Co-authored-by: sjoerdsimons <[email protected]>
|
I did test that the artifacts are being published with https://gitlab.collabora.com/tintou/callback-tests |
There was a problem hiding this comment.
Pull request overview
Adds an HTTP upload service so submitted LAVA jobs can return files for inclusion in GitLab artifact archives.
Changes:
- Adds per-job upload URLs and artifact storage.
- Integrates uploaded files into runner artifacts.
- Documents configuration and adds axum dependencies.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/upload.rs |
Implements upload storage and quotas. |
src/main.rs |
Integrates server, templates, and artifacts. |
README.md |
Documents artifact uploads. |
Cargo.toml |
Adds axum and Tokio features. |
Cargo.lock |
Locks new dependencies. |
Suppressed comments (1)
README.md:137
curl -Tsends a PUT request, while the router only registers POST, so this documented example receives 405 Method Not Allowed. Use a POST-producing curl option (or explicitly support PUT on the route).
- curl -T my-large-log.txt "{{ runner.ARTIFACT_UPLOAD_URL }}my-large-log.txt"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| run: | ||
| steps: | ||
| - curl -T my-large-log.txt "{{ runner.ARTIFACT_UPLOAD_URL }}my-large-log.txt" | ||
| ``` |
There was a problem hiding this comment.
Can you also test this documention in your test repo :) (basically for inline jobs)
|
Can you make your test repo public? No reason for it to be private :) I'm confused by this comment: "Also the upload URL will always be https, even though the service itself does not have TLS support" ; From a quick look i don't see https being enforced and really it shouldn't be. If i have a purely local network setup i should have the freedom to use http instead. For documentation going via the secrets mechanism makes a lot of sense even if lava secrets aren't as secretive as they should be. |
|
Also your MR talks about |
Add README sections describing: - How to enable the upload server (LAVA_ARTIFACT_UPLOAD_BASE_URL / LAVA_ARTIFACT_UPLOAD_LISTEN_ADDR env vars) - The runner.ARTIFACT_UPLOAD_URL template variable and how to use it from a LAVA job definition - How uploaded artifacts get included in GitLab job artifacts Co-authored-by: Copilot <[email protected]>
e3c141d to
fed7d50
Compare
Do not keep the lock on the UploadStore but on the job directly.
300555c to
49a579f
Compare
This is a rebase of #116 which is a rework of #17
We'd like to potentially add artifacts created by LAVA jobs to the archive stored by Gitlab. To achieve this, we run a cut-down web server on the lava-gitlab-runner that is able to respond to POST requests at
The LAVA job is able to know the upload URL because we introduce a new namespace for templated variables
runnerin the lava-gitlab-runner and addARTIFACT_UPLOAD_URLto it.It's still relatively complicated to get variables into LAVA tests; the pattern I used in my test repository
https://gitlab.collabora.com/tintou/callback-tests
is to create a parameter called
CALLBACK_URLin the test itself, and then in the job we can use a stanza like:to make it available to the test. Bear in mind, if you use this that LAVA does not automatically export parameters from environment variables so you will need to export it inside your
steps:in your test if you want to use it in scripts.The
keypart of the upload URL is a long random string. It's generated uniquely per Gitlab job, not per LAVA job, although this detail is not important unless you are performing multi-node tests.Because of the dynamic nature of the key, and the runner's port and IP, artifact upload is only possible for
submitjobs. Formonitorjobs, there's simply no way to communicate the necessary URL to them.Backing the webserver, there is a shared
UploadServerthat stores the uploaded artifacts, and bridges between the web server thread and the job thread. It stores aJobArtifactsfor each active job, which theArtifactStorecan query when we come to upload files. Uploaded artifacts are placed in the archive under exactly the relative<path>given in the upload URL (not automatically prefixed with the job ID, unlike the log/JUnit uploads), alongside the log/JUnit output, once the LAVA job finishes. Note however that it will require some significant reworking to support distinct directories for multi-node jobs. That's because we do not know how many nodes there are in the job until after we submit, at which point it's too late to create new keys for the other jobs. We could speculatively create a surplus, for example, but we couldn't then tie them to job IDs anyway.Uploads are disabled unless
LAVA_ARTIFACT_UPLOAD_BASE_URLis set on the runner; this is the externally reachable base URL of the upload endpoint (e.g.https://my-runner-host:8443/artifacts), for example for an appropriate reverse proxy. Optionally,LAVA_ARTIFACT_UPLOAD_LISTEN_ADDRcan be set to control the local address the upload server binds to (e.g.0.0.0.0:8443); it defaults to0.0.0.0:0(a random port). Uploads are capped at 1 GB per job.