Skip to content

Track ci minutes on a monthly basis [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Fabio Pitino requested to merge track-ci-minutes-monthly into master

What does this MR do?

Related to #277424 (closed)

In this MR we are introducing a way of tracking CI minutes on a monthly basis. Before this MR we only store CI minutes usage in namespace_statistics.shared_runners_seconds which is 1 record per namespace. On the 1st of each month we have a very large reset procedure that updates namespace_statistics, project_statistics and namespaces tables.

With moving to a monthly tracking, we can lazily generate records on the newly added ci_namespace_monthly_usages. This brings a few advantages:

  1. we can do this lazily and not requiring a mass update across all namespaces
  2. we have historical usage and we can generate charts for the view
  3. by creating a new record for the month we automatically zero-out the usage for the new month, rather than updating existing records.

The change is done behind feature flag ci_minutes_monthly_tracking which will be rolled out in https://gitlab.com/gitlab-org/gitlab/-/issues/300803.

In a follow-up MR we will be adding ci_project_monthly_usages to have a project-level tracking also.

Database migrations

rails db:migrate:redo VERSION=20210128152830

== 20210128152830 CreateCiNamespaceMonthlyUsage: reverting ====================
-- drop_table(:ci_namespace_monthly_usages)
   -> 0.0017s
== 20210128152830 CreateCiNamespaceMonthlyUsage: reverted (0.0084s) ===========

== 20210128152830 CreateCiNamespaceMonthlyUsage: migrating ====================
-- create_table(:ci_namespace_monthly_usages, {:if_not_exists=>true})
   -> 0.0105s
== 20210128152830 CreateCiNamespaceMonthlyUsage: migrated (0.0123s) ===========

Screenshots (strongly suggested)

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 Fabio Pitino

Merge request reports