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

archive_legacy_traces.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 92096e29ef10dba363823eddfe001cf1f27f348b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true
# rubocop:disable Style/Documentation

module Gitlab
  module BackgroundMigration
    class ArchiveLegacyTraces
      def perform(start_id, stop_id)
        # This background migration directly refers to ::Ci::Build model which is defined in application code.
        # In general, migration code should be isolated as much as possible in order to be idempotent.
        # However, `archive!` method is too complicated to be replicated by coping its subsequent code.
        # So we chose a way to use ::Ci::Build directly and we don't change the `archive!` method until 11.1
        ::Ci::Build.finished.without_archived_trace
          .where(id: start_id..stop_id).find_each do |build|
            begin
              build.trace.archive!
            rescue => e
              Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}"
            end
          end
      end
    end
  end
end