Skip to content

Extract CI::Minutes::Limit class

What does this MR do and why?

Related to #277447 (closed)

This MR extracts a class that deals exclusively with CI minutes limits.

While working on recalculate purchased CI minutes lazily I realized that there could be a concerning loop between:

  1. Ci::Minutes::Quota#current_usage calls Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current
  2. Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current needs to recalculate remaining purchased CI minutes
  3. The recalculation of purchased CI minutes invoked Ci::Minutes::Quota class (not current_usage)

While this doesn't represent a bug, since current_usage is not used when recalculating purchased CI minutes, it could be a problem if we make future changes that require current_usage.

To avoid this problem I've extracted Ci::Minutes::Limit class so it can be used instead of Ci::Minutes::Quota when recalculating purchased CI minutes: Quota#current_usage -> NamepaceMonthlyUsage.find_or_create_current -> Limit.recalculate_purchased_minutes!

The recalculate_purchased_minutes! will be introduced in the follow-up MR !73338 (merged).

In a follow-up issue we will need to rename Ci::Minutes::Quota with Ci::Minutes::Usage since "quota" and "limit" are synonyms. Our current Quota class deals with anything related to reading CI minutes data.

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

Loading