Class: Ci::Processable
Overview
Constant Summary
TaggableQueries::MAX_TAGS_IDS, TaggableQueries::TooManyTagsError
Constants included
from HasStatus
HasStatus::ACTIVE_STATUSES, HasStatus::ALIVE_STATUSES, HasStatus::AVAILABLE_STATUSES, HasStatus::BLOCKED_STATUS, HasStatus::CANCELABLE_STATUSES, HasStatus::COMPLETED_STATUSES, HasStatus::DEFAULT_STATUS, HasStatus::IGNORED_STATUSES, HasStatus::ORDERED_STATUSES, HasStatus::PASSED_WITH_WARNINGS_STATUSES, HasStatus::STARTED_STATUSES, HasStatus::STATUSES_ENUM, HasStatus::STOPPED_STATUSES, HasStatus::UnknownStatusError
Ci::Partitionable::MUTEX
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from Importable
#imported, #importing
Class Method Summary
collapse
Instance Method Summary
collapse
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
#cancel_gracefully?, #degenerate!, #degenerated?, #enqueue_immediately?, #ensure_metadata, #has_exposed_artifacts?, #id_tokens=, #id_tokens?, #interruptible, #interruptible=, #options, #options=, #set_enqueue_immediately!, #yaml_variables, #yaml_variables=
#archived?, #auto_canceled?, #cancelable?, #detailed_status, #duration, #expire_etag_cache!, #group_name, #has_trace?, #importing?, #latest?, #locking_enabled?, locking_enabled?, names, #playable?, #queued_duration, #recoverable?, #resource_parent, #sortable_name, #stage_name, #stuck?, switch_table_names, #to_ability_name, update_as_processed!, #update_older_statuses_retried!
#tags_ids
#bulk_insert_associations!, bulk_inserts_enabled?, with_bulk_insert
#present
#run_after_commit, #run_after_commit_or_now
Methods included from HasStatus
#active?, #blocked?, #complete?, #incomplete?, #started?
model_name, table_name_prefix
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
#serializable_hash
Class Method Details
.populate_scheduling_type! ⇒ Object
Old processables may have scheduling_type as nil, so we need to ensure the data exists before using it.
91
92
93
94
95
96
97
98
99
|
# File 'app/models/ci/processable.rb', line 91
def self.populate_scheduling_type!
needs = Ci::BuildNeed.scoped_build.select(1)
where(scheduling_type: nil).update_all(
"scheduling_type = CASE WHEN (EXISTS (#{needs.to_sql}))
THEN #{scheduling_types[:dag]}
ELSE #{scheduling_types[:stage]}
END"
)
end
|
.select_with_aggregated_needs(project) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/models/ci/processable.rb', line 77
def self.select_with_aggregated_needs(project)
aggregated_needs_names = Ci::BuildNeed
.scoped_build
.select("ARRAY_AGG(name)")
.to_sql
all.select(
'*',
"(#{aggregated_needs_names}) as aggregated_needs_names"
)
end
|
Instance Method Details
#action? ⇒ Boolean
139
140
141
|
# File 'app/models/ci/processable.rb', line 139
def action?
raise NotImplementedError
end
|
#aggregated_needs_names ⇒ Object
131
132
133
|
# File 'app/models/ci/processable.rb', line 131
def aggregated_needs_names
read_attribute(:aggregated_needs_names)
end
|
#all_dependencies ⇒ Object
203
204
205
206
207
|
# File 'app/models/ci/processable.rb', line 203
def all_dependencies
strong_memoize(:all_dependencies) do
dependencies.all
end
end
|
#all_met_to_become_pending? ⇒ Boolean
160
161
162
|
# File 'app/models/ci/processable.rb', line 160
def all_met_to_become_pending?
super && !with_resource_group?
end
|
#clone(current_user:, new_job_variables_attributes: []) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'app/models/ci/processable.rb', line 110
def clone(current_user:, new_job_variables_attributes: [])
new_attributes = self.class.clone_accessors.index_with do |attribute|
public_send(attribute) end
if persisted_environment.present?
new_attributes[:metadata_attributes] ||= {}
new_attributes[:metadata_attributes][:expanded_environment_name] = expanded_environment_name
end
new_attributes[:user] = current_user
self.class.new(new_attributes)
end
|
#dependency_variables ⇒ Object
195
196
197
198
199
200
201
|
# File 'app/models/ci/processable.rb', line 195
def dependency_variables
return [] if all_dependencies.empty?
Gitlab::Ci::Variables::Collection.new.concat(
Ci::JobVariable.where(job: all_dependencies).dotenv_source
)
end
|
#ensure_scheduling_type! ⇒ Object
187
188
189
190
191
192
193
|
# File 'app/models/ci/processable.rb', line 187
def ensure_scheduling_type!
return if scheduling_type
pipeline.ensure_scheduling_type!
reset
end
|
#expanded_environment_name ⇒ Object
151
152
153
|
# File 'app/models/ci/processable.rb', line 151
def expanded_environment_name
raise NotImplementedError
end
|
#find_legacy_scheduling_type ⇒ Object
scheduling_type column of previous builds/bridges have not been populated, so we calculate this value on runtime when we need it.
175
176
177
178
179
|
# File 'app/models/ci/processable.rb', line 175
def find_legacy_scheduling_type
strong_memoize(:find_legacy_scheduling_type) do
needs.exists? ? :dag : :stage
end
end
|
#needs_attributes ⇒ Object
181
182
183
184
185
|
# File 'app/models/ci/processable.rb', line 181
def needs_attributes
strong_memoize(:needs_attributes) do
needs.map { |need| need.attributes.except('id', 'build_id') }
end
end
|
#other_manual_actions ⇒ Object
143
144
145
|
# File 'app/models/ci/processable.rb', line 143
def other_manual_actions
pipeline.manual_actions.reject { |action| action.name == name }
end
|
#persisted_environment ⇒ Object
155
156
157
|
# File 'app/models/ci/processable.rb', line 155
def persisted_environment
raise NotImplementedError
end
|
#retryable? ⇒ Boolean
125
126
127
128
129
|
# File 'app/models/ci/processable.rb', line 125
def retryable?
return false if retried? || archived? || deployment_rejected?
success? || failed? || canceled?
end
|
#schedulable? ⇒ Boolean
135
136
137
|
# File 'app/models/ci/processable.rb', line 135
def schedulable?
raise NotImplementedError
end
|
#scheduling_type_dag? ⇒ Boolean
Overriding scheduling_type enum’s method for nil ‘scheduling_type`s
169
170
171
|
# File 'app/models/ci/processable.rb', line 169
def scheduling_type_dag?
scheduling_type.nil? ? find_legacy_scheduling_type == :dag : super
end
|
#when ⇒ Object
147
148
149
|
# File 'app/models/ci/processable.rb', line 147
def when
read_attribute(:when) || 'on_success'
end
|
#with_resource_group? ⇒ Boolean
164
165
166
|
# File 'app/models/ci/processable.rb', line 164
def with_resource_group?
self.resource_group_id.present?
end
|