Skip to content

Commit

Permalink
fix: guard against unparsable nightly release names in cleanup script (
Browse files Browse the repository at this point in the history
…#3086)

I discovered this issue while testing the cleanup script in stage, which had a release with a name like "Firefox-mozilla-central-nightly-20170731100325-2". The dry run of the cleanup script worked fine, but when it tried to delete it threw an error about not being able to parse it as a date. After some digging, I discovered that this is because the dryrun's `SELECT` uses an index, while the `DELETE` does not. (I don't know why this is - but it doesn't affect the behaviour of the script beyond making the `DELETE` look at some rows that it won't be deleting anayways...)

In any case, we may as well make sure the names we're about to parse are actually parsable.
  • Loading branch information
bhearsum committed Jan 16, 2024
1 parent 5e7bd50 commit 40466b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/manage-db.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
sys.path.append(path.join(path.dirname(__file__), path.join("..", "vendor", "lib", "python")))


# TODO: filter out things that don't end in 14 digits
RELEASES_CLEANUP_CONDITION = """
LEFT JOIN rules rules_mapping ON (name=rules_mapping.mapping)
WHERE name LIKE '%%nightly%%'
AND name NOT LIKE '%%latest'
AND rules_mapping.mapping IS NULL
AND RIGHT(name, 14) REGEXP '^[[:digit:]]*$'
AND (STR_TO_DATE(RIGHT(name, 14), "%%Y%%m%%d%%H%%i%%S") < NOW() - INTERVAL {nightly_age} DAY);
"""

Expand Down

0 comments on commit 40466b8

Please sign in to comment.