Fix dead condition as resetting CI minutes usage is always successful
Problem
When an admin attempts to reset CI minutes consumption for a namespace we use Ci::Minutes::ResetUsageService#execute
. This service always returns true
since underneath it uses update_all
which returns a truthy value (the count of updated records).
In the controller where we use the service object we check for the output of the service. If true
we return a success message to the user. If false
we return an error. The false
scenario can't occur in reality, unless an exception is raised, but it won't be rescued gracefully.
We realized about this when resetting CI minutes notifications for new monthly tracking: !69063 (comment 679747397).
Solution
Consider either:
- removing the
if
statement in the controllersAdmin::GroupsController#reset_runner_minutes
andAdmin::UsersController#reset_runner_minutes
to always return a success message - rescue exceptions in
Ci::Minutes::ResetUsageService
and returnfalse
Edited by Fabio Pitino