Skip to content

Update ProjectStatistics with pipeline artifacts

Ref: #234032 (closed)

What does this MR do?

This MR updates pipeline_artifact_size in ProjectStatistics when a new PipelineArtifact has been created.

Why are we doing this?

You can visualize how much data is being stored on with your gitlab instance by visiting this page.

Following up !39607 (merged) where we introduced our new column in ProjectStatistics.

This MR makes sure we increment artifacts statistics after record creation.

This is similar to what we already do with our BuildArtifact.

SQL output on record creation

This is what's happening on the rails console once we create a new PipelineArtifact:

  Ci::PipelineArtifact Create (1.1ms)  INSERT INTO "ci_pipeline_artifacts" ("created_at", "updated_at", "pipeline_id", "project_id", "size", "file_store", "file_type", "file_format", "file") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"  [["created_at", "2020-08-18 15:25:55.119729"], ["updated_at", "2020-08-18 15:25:55.119729"], ["pipeline_id", 162], ["project_id", 21], ["size", 8], ["file_store", 1], ["file_type", 1], ["file_format", 1], ["file", "unnamed"]]
  Ci::PipelineArtifact Update (0.6ms)  UPDATE "ci_pipeline_artifacts" SET "file_store" = $1 WHERE "ci_pipeline_artifacts"."id" = $2  [["file_store", 1], ["id", 12]]
   (0.4ms)  COMMIT
  ProjectStatistics Update All (1.0ms)  UPDATE "project_statistics" SET pipeline_artifacts_size = COALESCE(pipeline_artifacts_size, 0) + (8), storage_size = COALESCE(storage_size, 0) + (8) WHERE "project_statistics"."project_id" = $1  [["project_id", 21]]

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Max Orefice

Merge request reports