Fix CI artifact sizes not logged for some runner endpoints
What does this MR do and why?
!88140 (merged) may have quietly broken the logging for the GET /api/:version/jobs/:id/artifacts
endpoint. Since log_artifact_size
was previously defined as a runner API helper and a general API helper, the runner API version won. This caused the lazy attribute loader to discard the artifact
since it was a JobArtifactUploader
type instead of Ci::JobArtifact
.
We can fix this by renaming the method to log_artifact_file_size
and adding a test to ensure the right type is called.
Relates to #369033 (closed)
How to set up and validate locally
- Create a CI job with stages that pass artifacts:
image: alpine:latest
test:
script:
- mkdir -p test
- echo "hello" > test/test.txt
artifacts:
paths:
- test
cache:
paths:
- test
deploy:
stage: deploy
script:
- echo hello
- Observe
/var/log/gitlab/gitlab-rails/api_json.log
has ameta.artifact_size
:
$ grep 'GET /api/:version/jobs/:id/artifacts' api_json.log | jq | grep artifact_size
"meta.artifact_size": 599,
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Stan Hu