Skip to content

Fix CI artifact sizes not logged for some runner endpoints

Stan Hu requested to merge sh-fix-artifacts-logging into master

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

  1. 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
  1. Observe /var/log/gitlab/gitlab-rails/api_json.log has a meta.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.

Edited by Stan Hu

Merge request reports

Loading