Class: Ci::Processable
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::EXCLUDE_IGNORED_STATUSES, HasStatus::ORDERED_STATUSES, HasStatus::PASSED_WITH_WARNINGS_STATUSES, HasStatus::STARTED_STATUSES, HasStatus::STATUSES_ENUM, HasStatus::STOPPED_STATUSES, HasStatus::UnknownStatusError
ApplicationRecord::MAX_PLUCK
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!
#clear_memoization, #strong_memoize, #strong_memoized?
#archived?, #auto_canceled?, bulk_insert_tags!, #cancelable?, #detailed_status, #duration, #expire_etag_cache!, #failed_but_allowed?, #group_name, #has_trace?, #importing?, #latest?, #locking_enabled?, locking_enabled?, names, #playable?, #queued_duration, #recoverable?, #sortable_name, #stuck?, 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?, #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.
85
86
87
88
89
90
91
92
93
|
# File 'app/models/ci/processable.rb', line 85
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
71
72
73
74
75
76
77
78
79
80
81
|
# File 'app/models/ci/processable.rb', line 71
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
133
134
135
|
# File 'app/models/ci/processable.rb', line 133
def action?
raise NotImplementedError
end
|
#aggregated_needs_names ⇒ Object
125
126
127
|
# File 'app/models/ci/processable.rb', line 125
def aggregated_needs_names
read_attribute(:aggregated_needs_names)
end
|
#all_dependencies ⇒ Object
193
194
195
196
197
|
# File 'app/models/ci/processable.rb', line 193
def all_dependencies
strong_memoize(:all_dependencies) do
dependencies.all
end
end
|
#all_met_to_become_pending? ⇒ Boolean
150
151
152
|
# File 'app/models/ci/processable.rb', line 150
def all_met_to_become_pending?
super && !with_resource_group?
end
|
#clone(current_user:) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'app/models/ci/processable.rb', line 104
def clone(current_user:)
new_attributes = self.class.clone_accessors.to_h do |attribute|
[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
185
186
187
188
189
190
191
|
# File 'app/models/ci/processable.rb', line 185
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
177
178
179
180
181
182
183
|
# File 'app/models/ci/processable.rb', line 177
def ensure_scheduling_type!
return if scheduling_type
pipeline.ensure_scheduling_type!
reset
end
|
#expanded_environment_name ⇒ Object
141
142
143
|
# File 'app/models/ci/processable.rb', line 141
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.
165
166
167
168
169
|
# File 'app/models/ci/processable.rb', line 165
def find_legacy_scheduling_type
strong_memoize(:find_legacy_scheduling_type) do
needs.exists? ? :dag : :stage
end
end
|
#needs_attributes ⇒ Object
171
172
173
174
175
|
# File 'app/models/ci/processable.rb', line 171
def needs_attributes
strong_memoize(:needs_attributes) do
needs.map { |need| need.attributes.except('id', 'build_id') }
end
end
|
#persisted_environment ⇒ Object
145
146
147
|
# File 'app/models/ci/processable.rb', line 145
def persisted_environment
raise NotImplementedError
end
|
#retryable? ⇒ Boolean
119
120
121
122
123
|
# File 'app/models/ci/processable.rb', line 119
def retryable?
return false if retried? || archived? || deployment_rejected?
success? || failed? || canceled?
end
|
#schedulable? ⇒ Boolean
129
130
131
|
# File 'app/models/ci/processable.rb', line 129
def schedulable?
raise NotImplementedError
end
|
#scheduling_type_dag? ⇒ Boolean
Overriding scheduling_type enum's method for nil `scheduling_type`s
159
160
161
|
# File 'app/models/ci/processable.rb', line 159
def scheduling_type_dag?
scheduling_type.nil? ? find_legacy_scheduling_type == :dag : super
end
|
#when ⇒ Object
137
138
139
|
# File 'app/models/ci/processable.rb', line 137
def when
read_attribute(:when) || 'on_success'
end
|
#with_resource_group? ⇒ Boolean
154
155
156
|
# File 'app/models/ci/processable.rb', line 154
def with_resource_group?
self.resource_group_id.present?
end
|