Merge branch '44922-fix-build-metadata-creation' into 'master'
Resolve "ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_ci_builds_meta..." Closes #44922 See merge request gitlab-org/gitlab-ce!18155
This commit is contained in:
commit
88e3b8ec27
|
@ -45,7 +45,7 @@
|
|||
return `#${this.job.runner.id}`;
|
||||
},
|
||||
hasTimeout() {
|
||||
return this.job.metadata != null && this.job.metadata.timeout_human_readable !== '';
|
||||
return this.job.metadata != null && this.job.metadata.timeout_human_readable !== null;
|
||||
},
|
||||
timeout() {
|
||||
if (this.job.metadata == null) {
|
||||
|
|
|
@ -90,6 +90,7 @@ module Ci
|
|||
before_save :ensure_token
|
||||
before_destroy { unscoped_project }
|
||||
|
||||
before_create :ensure_metadata
|
||||
after_create unless: :importing? do |build|
|
||||
run_after_commit { BuildHooksWorker.perform_async(build.id) }
|
||||
end
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
class BuildMetadataEntity < Grape::Entity
|
||||
expose :timeout_human_readable do |metadata|
|
||||
metadata.timeout_human_readable unless metadata.timeout.nil?
|
||||
end
|
||||
|
||||
expose :timeout_human_readable
|
||||
expose :timeout_source do |metadata|
|
||||
metadata.present.timeout_source
|
||||
end
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :ci_build_metadata, class: Ci::BuildMetadata do
|
||||
build factory: :ci_build
|
||||
|
||||
after(:build) do |build_metadata, _|
|
||||
build_metadata.project ||= build_metadata.build.project
|
||||
end
|
||||
end
|
||||
end
|
|
@ -13,7 +13,7 @@ describe Ci::BuildMetadata do
|
|||
end
|
||||
|
||||
let(:build) { create(:ci_build, pipeline: pipeline) }
|
||||
let(:build_metadata) { create(:ci_build_metadata, build: build) }
|
||||
let(:build_metadata) { build.metadata }
|
||||
|
||||
describe '#update_timeout_state' do
|
||||
subject { build_metadata }
|
||||
|
|
Loading…
Reference in New Issue