Guard worker thresholds applications settings time conversion bug
🔥 Problem
The Guard worker has a property that we call long running threshold. That value is used to detect long running migrations. More exactly, it is used for migrations in state pre_importing
and importing
for too long. Those migrations need to be actively canceled by the Guard worker.
In !87324 (merged), we introduced to read those thresholds out of application settings (instead of a hard code value).
After toggle the related feature flag to use them, we observed a few long running migrations not being picked up by the Guard worker.
Upon close inspection, we saw job failures with the following message:
NoMethodError
undefined method `ago' for 1800:Integer
app/workers/container_registry/migration/guard_worker.rb:77:in `long_running_migration?'
Basically, we read the value from the application settings and that value is an integer. We then try to call #ago
on it. #ago
is not defined on Integer
.
🚒 Solution
- Before calling
#ago
, call#seconds
. - Update the specs so that application settings value are stubbed to an
Integer
and not anActiveSupport::Duration