From ebc3d2a368f9f27f36002c48255b12dba74a7e9e Mon Sep 17 00:00:00 2001 From: Luke Duncalfe <lduncalfe@eml.cc> Date: Fri, 25 Oct 2024 17:39:03 +1300 Subject: [PATCH] Return changes sorted by most overdue to least Previously the keep would return changes sorted alphabetically by name of migration file. This change returns the changes by most to least overdue. --- keeps/overdue_finalize_background_migration.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/keeps/overdue_finalize_background_migration.rb b/keeps/overdue_finalize_background_migration.rb index c9f23665aabcf..d491c2d471a6a 100644 --- a/keeps/overdue_finalize_background_migration.rb +++ b/keeps/overdue_finalize_background_migration.rb @@ -25,7 +25,7 @@ module Keeps # ``` class OverdueFinalizeBackgroundMigration < ::Gitlab::Housekeeper::Keep def each_change - each_batched_background_migration do |migration_yaml_file, migration| + batched_background_migrations.each do |migration_yaml_file, migration| next unless before_cuttoff_milestone?(migration['milestone']) job_name = migration['migration_job_name'] @@ -219,10 +219,12 @@ def before_cuttoff_milestone?(milestone) Gem::Version.new(milestone) <= Gem::Version.new(::Gitlab::Database.min_schema_gitlab_version) end - def each_batched_background_migration - all_batched_background_migration_files.map do |f| - yield(f, YAML.load_file(f)) + def batched_background_migrations + migrations = all_batched_background_migration_files.index_with do |f| + YAML.load_file(f) end + + migrations.sort_by { |_f, migration| Gitlab::VersionInfo.parse_from_milestone(migration['milestone']) } end def all_batched_background_migration_files -- GitLab