Class: Ci::RunningBuild
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationRecord
- Ci::RunningBuild
- Includes:
- Partitionable, SafelyChangeColumnDefault
- Defined in:
- app/models/ci/running_build.rb
Overview
This model represents metadata for a running build. Despite the generic RunningBuild name, in this first iteration it applies only to shared runners
(see Ci::RunningBuild.upsert_shared_runner_build!).
The decision to insert all of the running builds here was deferred to avoid the pressure on the database as at this time that was not necessary. We can reconsider the decision to limit this only to shared runners when there is more evidence that inserting all of the running builds there is worth the additional pressure.
Constant Summary
Constants included from Partitionable
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary collapse
Methods inherited from ApplicationRecord
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from SensitiveSerializableHash
Class Method Details
.upsert_shared_runner_build!(build) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/ci/running_build.rb', line 25 def self.upsert_shared_runner_build!(build) unless build.shared_runner_build? raise ArgumentError, 'build has not been picked by a shared runner' end entry = self.new( build: build, project: build.project, runner: build.runner, runner_type: build.runner.runner_type ) entry.validate! self.upsert(entry.attributes.compact, returning: %w[build_id], unique_by: :build_id) end |