In order to fully deprecate the legacy CI minutes reset method, we must switch the mechanism that reads the "current CI minutes usage" from the legacy NamespaceStatistics#shared_runners_seconds to using the new Ci::Minutes::NamespaceMonthlyUsage#amount_used.
Proposal
The problem is that we reference shared_runners_seconds in many places in the codebase and especially the specs.
We need to first ensure that we reduce the direct references to shared_runners_seconds to a minimum:
Consistently use Ci::Minutes::Quota#total_minutes_used instead of shared_runners_seconds
@fabiopitino Can this issue be worked on in parallel with #277447 (closed)? Or maybe we should prioritize the displaying usage data over the ability to add purchased minutes? (Any possibility Fulfillment can help us with that issue? Wishful thinking probably... )
@cheryl.li I've made this issue blocked by#277447 (closed) because when we display data about the current quota it would be better to pull all the data from the same table (monthly limit + additional minutes limit). Also #277447 (closed) takes care of populating the additional minutes for the new tables so we still depend on that, unfortunately.
@fabiopitino It would depend on what their PM has scheduled for their next few milestones. I think we should arrange a sync call for our teams to discuss our current plans, potential overlap, and how to best support this (e.g. splitting off work if they had bandwidth, for example). I put out a discussion on Slack #f_ci_minutes to discuss further.
@cheryl.li - Can you provide a reference in the description for where we are talking about this being displayed? I couldn't tell if this was in Group Admin pages in the application or in some internally functioning data dashboard. Second - is it fair to say that this shift will mean we will temporarily not show as much historical data?
@fabiopitino Can you confirm that the code would account for data in both tables (old and new storage) during the "transition" when displaying CI minutes usage?
@cheryl.li not sure I got the question right. We already store both old and new/monthly data. When we transition from displaying old to new during the deployment we should not expect downtime since we are tracking minutes consumption on both tables today.
The usage data (old mechanism) is being displayed in Group admin page or User profile page depending whether the entity is a Group or personal namespace.
This change will also affect where the current consumption is read from when enforcing CI minutes. Example: to know whether the user has used up all their minutes we pull the consumption from the new table rather than the old one.
@fabiopitino Apologies for the poorly worded question. I just meant that I'd presume the "Usage view" would render the data correctly, regardless of how we're storing the usage data (e.g. the old vs new way with monthly historical tracking). I think you answered it for me though!
@jreporter@cheryl.li This is at risk. I'm realizing that it requires more work than expected. In particular we use shared_runners_seconds more than 100 times in our code. We would need a few extra refactoring MRs for this issue to introduce an abstraction layer where we can finally swap the implementation with the new database column.
@jreporter@cheryl.li after giving it more thoughts I'm proposing the following plan:
Refactor the use of shared_runners_seconds behind an abstraction method
Introduce a feature flag that allows switching the read of current CI usage from legacy namespace_statistics.shared_runners_seconds to new ci_namespace_monthly_usage.amount_used
This means that this issue can take care of (1) and (2) above and we don't need to do #277449 (closed) since it will happen automatically when we enable the feature flag in (4).
Let me know if you have any questions otherwise I will go and update the various issues.
moving this back to on track since we moved the milestone.
However, currently there are no tangible progress on this issue yet due to focusing on closing other issues in progress first. I will start to lay the groundwork for this tomorrow.
Fabio Pitinochanged title from Configuremonthly stored CI minutes usage for displaying usage data to Refactoring: remove direct references to shared_runners_seconds
changed title from Configuremonthly stored CI minutes usage for displaying usage data to Refactoring: remove direct references to shared_runners_seconds
Fabio Pitinochanged the descriptionCompare with previous version