guardian / grid

The Guardian’s image management system
https://www.theguardian.com/info/developer-blog/2015/aug/12/open-sourcing-grid-image-service
Apache License 2.0
1.44k stars 119 forks source link

make reaper schedule behave more like cron #4197

Closed twrichards closed 7 months ago

twrichards commented 7 months ago

We noticed that the SoftReapingTooMuch & HardReapingTooMuch alarms (added in https://github.com/guardian/editorial-tools-platform/pull/712) were firing on re-deploys of the grid, since reaper was running with no delay on startup then every 15mins thereafter. We decided that best to ensure reaper only runs at the interval specified as that makes it easier to reason about (and changing the alarms would be hard without compromising their utility/promptness).

What does this change?

This introduces a util function for finding the time/duration until the next instance of an interval, past the hour... e.g. if 'now' is 11:11:31 then the next instance of the interval will be 11:15:00 and so the duration until then is 3min 29sec. This functionality has tests 🎉 .

This function is then used for the initialDelay when starting the reaper schedule in thrall.

How should a reviewer test this change?

Do multiple deploys to TEST in quick succession and see that reaper still only runs (can be observed via CloudWatch metrics: SoftReaped & HardReaped) on 00, 15, 30 & 45 mins past the hour.

github-actions[bot] commented 7 months ago

Deploy build 12118 to TEST

All deployment options - [Deploy build 12118 to TEST](https://riffraff.gutools.co.uk/deployment/deployAgain?project=media-service%3A%3Agrid%3A%3Aall&build=12118&stage=TEST&updateStrategy=MostlyHarmless&action=deploy) - [Deploy parts of build 12118 to TEST by previewing it first](https://riffraff.gutools.co.uk/preview/yaml?project=media-service%3A%3Agrid%3A%3Aall&build=12118&stage=TEST&updateStrategy=MostlyHarmless)

From guardian/actions-riff-raff.

prout-bot commented 7 months ago

Seen on cropper, kahuna, auth, metadata-editor (merged by @twrichards 9 minutes and 55 seconds ago) Please check your changes!

prout-bot commented 7 months ago

Seen on image-loader, usage (merged by @twrichards 10 minutes and 3 seconds ago) Please check your changes!

prout-bot commented 7 months ago

Seen on leases, media-api (merged by @twrichards 10 minutes and 8 seconds ago) Please check your changes!

prout-bot commented 7 months ago

Seen on collections, thrall (merged by @twrichards 10 minutes and 15 seconds ago) Please check your changes!

prout-bot commented 7 months ago

Seen on collections (merged by @twrichards 10 minutes and 15 seconds ago) Please check your changes!

prout-bot commented 7 months ago

Seen on collections, thrall (merged by @twrichards 10 minutes and 16 seconds ago) Please check your changes!