Skip to content

Add shared_runners_duration column to CI minutes tracking

Fabio Pitino requested to merge ci-track-shared-runners-usage-duration into master

What does this MR do and why?

Related to #254231 (closed)

The goal for #254231 (closed) is to track the duration (in seconds) of shared runners at project and namespace level. This tracking should happen regardless of whether the project is using CI minutes (intended as the duration * cost_factor calculation). For example the majority of public projects today are exempt from CI minutes but we don't know how much of the shared runners they are using.

This new columns are the place were we will be accumulating the total duration of shared runners usage regardless of CI minutes usage or exemption.

Database migration

$ rails db:migrate
== 20211008181451 AddSharedRunnersDurationToCiNamespaceMonthlyUsages: migrating
-- add_column(:ci_namespace_monthly_usages, :shared_runners_duration, :integer, {:default=>0, :null=>false})
   -> 0.0054s
== 20211008181451 AddSharedRunnersDurationToCiNamespaceMonthlyUsages: migrated (0.0054s)

== 20211008182954 AddSharedRunnersDurationToCiProjectMonthlyUsages: migrating =
-- add_column(:ci_project_monthly_usages, :shared_runners_duration, :integer, {:default=>0, :null=>false})
   -> 0.0030s
== 20211008182954 AddSharedRunnersDurationToCiProjectMonthlyUsages: migrated (0.0031s)


$ rails db:rollback STEP=2
== 20211008182954 AddSharedRunnersDurationToCiProjectMonthlyUsages: reverting =
-- remove_column(:ci_project_monthly_usages, :shared_runners_duration, :integer, {:default=>0, :null=>false})
   -> 0.0019s
== 20211008182954 AddSharedRunnersDurationToCiProjectMonthlyUsages: reverted (0.0036s)

== 20211008181451 AddSharedRunnersDurationToCiNamespaceMonthlyUsages: reverting
-- remove_column(:ci_namespace_monthly_usages, :shared_runners_duration, :integer, {:default=>0, :null=>false})
   -> 0.0020s
== 20211008181451 AddSharedRunnersDurationToCiNamespaceMonthlyUsages: reverted (0.0021s)

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

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

Merge request reports