Skip to content
Snippets Groups Projects

BG migration to fix incorrect job artifacts expire_at on self-managed

Merged Albert requested to merge 355833-migration-to-fix-incorrect-expire-at into master
Compare and Show latest version
2 files
+ 82
3
Compare changes
  • Side-by-side
  • Inline
Files
2
module Gitlab
module Gitlab
module BackgroundMigration
module BackgroundMigration
class RemoveBackfilledJobArtifactsExpireAt < BatchedMigrationJob
class RemoveBackfilledJobArtifactsExpireAt < BatchedMigrationJob
BATCH_SIZE = 1_000
# This detects and fixes job artifacts that have `expire_at` wrongly backfilled by the migration
# This detects and fixes job artifacts that have `expire_at` wrongly backfilled by the migration
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47723.
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47723.
# These job artifacts will not be deleted and will have their `expire_at` removed.
# These job artifacts will not be deleted and will have their `expire_at` removed.
@@ -20,7 +18,7 @@ class RemoveBackfilledJobArtifactsExpireAt < BatchedMigrationJob
@@ -20,7 +18,7 @@ class RemoveBackfilledJobArtifactsExpireAt < BatchedMigrationJob
# Therefore job artifacts that have `expire_at` exactly on the 00, 30 or 45 minute mark
# Therefore job artifacts that have `expire_at` exactly on the 00, 30 or 45 minute mark
# on the dates 21, 22, 23 of the month will not be deleted.
# on the dates 21, 22, 23 of the month will not be deleted.
# https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
# https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
EXPIRES_ON_21_22_23_AT_MIDNIGHT_IN_TIMEZONE = <<~SQL
EXPIRES_ON_21_22_23_AT_MIDNIGHT_IN_TIMEZONE = <<~SQL.freeze
EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23)
EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23)
AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45)
AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45)
AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0
AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0
Loading