Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/database/background_migration/health_status.rb')
-rw-r--r--lib/gitlab/database/background_migration/health_status.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/gitlab/database/background_migration/health_status.rb b/lib/gitlab/database/background_migration/health_status.rb
new file mode 100644
index 00000000000..01f9c5eb5fd
--- /dev/null
+++ b/lib/gitlab/database/background_migration/health_status.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Database
+ module BackgroundMigration
+ module HealthStatus
+ # Rather than passing along the migration, we use a more explicitly defined context
+ Context = Struct.new(:tables)
+
+ def self.evaluate(migration, indicator = Indicators::AutovacuumActiveOnTable)
+ signal = begin
+ indicator.new(migration.health_context).evaluate
+ rescue StandardError => e
+ Gitlab::ErrorTracking.track_exception(e, migration_id: migration.id,
+ job_class_name: migration.job_class_name)
+ Signals::Unknown.new(indicator, reason: "unexpected error: #{e.message} (#{e.class})")
+ end
+
+ log_signal(signal, migration) if signal.log_info?
+
+ signal
+ end
+
+ def self.log_signal(signal, migration)
+ Gitlab::AppLogger.info(
+ message: "#{migration} signaled: #{signal}",
+ migration_id: migration.id
+ )
+ end
+ end
+ end
+ end
+end