diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 77d275f304d..61c10c427dd 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -19,18 +19,13 @@ module Ci has_one :last_deployment, -> { order('deployments.id DESC') }, as: :deployable, class_name: 'Deployment' has_many :trace_sections, class_name: 'Ci::BuildTraceSection' - has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :job_id, dependent: :destroy, inverse_of: :job # rubocop:disable Cop/ActiveRecordDependent has_one :job_artifacts_archive, -> { where(file_type: Ci::JobArtifact.file_types[:archive]) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id has_one :job_artifacts_metadata, -> { where(file_type: Ci::JobArtifact.file_types[:metadata]) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id has_one :job_artifacts_trace, -> { where(file_type: Ci::JobArtifact.file_types[:trace]) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id -<<<<<<< HEAD - has_many :chunks, class_name: 'Ci::JobTraceChunk', foreign_key: :job_id - -======= ->>>>>>> live-trace-v2 has_one :metadata, class_name: 'Ci::BuildMetadata' delegate :timeout, to: :metadata, prefix: true, allow_nil: true delegate :gitlab_deploy_token, to: :project diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index 00f7e1a121d..95a8a4eb1ad 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -19,9 +19,8 @@ module Ci db: 2 } -<<<<<<< HEAD:app/models/ci/job_trace_chunk.rb def self.delayed_cleanup_blk - ids = all.redis.pluck(:job_id, :chunk_index).map do |data| + ids = all.redis.pluck(:build_id, :chunk_index).map do |data| "gitlab:ci:trace:#{data.first}:chunks:#{data.second}:data" end @@ -44,10 +43,8 @@ module Ci end end -======= ## # Data is memoized for optimizing #size and #end_offset ->>>>>>> live-trace-v2:app/models/ci/build_trace_chunk.rb def data @data ||= get_data end diff --git a/app/models/project.rb b/app/models/project.rb index 512f16d2f05..48e30f0fd36 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -228,7 +228,7 @@ class Project < ActiveRecord::Base # still using `dependent: :destroy` here. has_many :builds, class_name: 'Ci::Build', inverse_of: :project, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :build_trace_section_names, class_name: 'Ci::BuildTraceSectionName' - has_many :build_trace_chunks, class_name: 'Ci::JobTraceChunk', foreign_key: :job_id, through: :builds, source: :chunks + has_many :build_trace_chunks, class_name: 'Ci::BuildTraceChunk', through: :builds, source: :trace_chunks has_many :runner_projects, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' has_many :variables, class_name: 'Ci::Variable' diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb index d04f1c7fc15..1cb1b3edf50 100644 --- a/app/workers/build_finished_worker.rb +++ b/app/workers/build_finished_worker.rb @@ -8,7 +8,7 @@ class BuildFinishedWorker Ci::Build.find_by(id: build_id).try do |build| # Swap all trace chunks to Database from Redis # TODO: Do we need that? - build.chunks.redis.map(&:use_database!) + build.trace_chunks.redis.map(&:use_database!) # We execute that in sync as this access the files in order to access local data, and reduce IO BuildTraceSectionsWorker.new.perform(build.id) diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index dc005a2e508..e31d9b70466 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -111,7 +111,7 @@ module Gitlab if job.trace_chunks.any? Gitlab::Ci::Trace::ChunkedIO.new(job) do |stream| archive_stream!(stream) - stream.delete! + stream.destroy! end elsif current_path File.open(current_path) do |stream| diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index e7f20f81fe0..e668e9a846b 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -276,6 +276,7 @@ project: - uploads - members_and_requesters - build_trace_section_names +- build_trace_chunks - root_of_fork_network - fork_network_member - fork_network