Track ci minutes on a monthly basis [RUN ALL RSPEC] [RUN AS-IF-FOSS]
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:
- we can do this lazily and not requiring a mass update across all namespaces
- we have historical usage and we can generate charts for the view
- 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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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