Gusto / it-cpe-opensource

Tools used by the CPE team at Gusto to manage our endpoints and software deployment systems.
Other
59 stars 29 forks source link

Fix sub-day auto promotion #177

Closed noizwaves closed 5 months ago

noizwaves commented 5 months ago

After waiting ~22 hours for a package to be promoted on Gusto's ultra-fast (i.e. 0.25) channel, I started digging into why.

Problem

The logs indicate the gusto_scope package was not eligible for promotion. This repo is using this logic to calculate how many days have passed. It uses the days attribute, which represents the whole number of days of a time span excluding any remaining seconds:

>>> arrow.now() - last_promoted
datetime.timedelta(seconds=78916, microseconds=943201)

>>> (arrow.now() - last_promoted).days
0

Using the existing logic, this package was last promoted 0 days ago, but when considering seconds, it was actually last promoted ~0.91 days ago:

>>> (arrow.now() - last_promoted).seconds / 86400
0.916238425925926

This seconds component is essential for quickly promoted packages, that may have a channel shifted promotion period much less than 1.0.

Solution

When computing the "days since promotion", include the seconds component.

noizwaves commented 5 months ago

Thanks @DPS-gusto!

noizwaves commented 5 months ago

And it worked! https://github.com/Gusto/cpe-autopkg-pipeline/actions/runs/8729852904/job/23952612906#step:10:2270