Use build's month for the duration calculation in monthly usage
This issue is to use build's month so that the worker adds its duration to the correct month.
Why are we doing this work
A production spike has appeared and an issue #420342 (closed) is logged by the bot.
This is one of the problems we need to resolve: to use build's month to add its duration to the correct monthly usage.
Click to expand the investigation
The failed workers for the month end 2023-07-31
will eventually succeed on 2023-08-01
because of the project and namespace monthly usage's current_month
scope (it's 2023-07-01
when the workers failed, and it's 2023-08-01
when the workers succeeded). As we can now see, the retry list has no failed worker related to Ci::Minutes::UpdateProjectAndNamespaceUsageWorker
and is empty:
[ gprd ] production> rs = Sidekiq::RetrySet.new
[ gprd ] production> rs.size
=> 328
[ gprd ] production> list = rs.select { |job| job.klass == "Ci::Minutes::UpdateProjectAndName
spaceUsageWorker" }
=> []
However, the durations are added to the wrong month 2023-08-01
. To resolve this, we should change to use the build's created_at
's month to be the month that we should add the duration to.
Relevant links
Non-functional requirements
-
Documentation: -
Feature flag: -
Performance: -
Testing: