Skip to content
代码片段 群组 项目
未验证 提交 c12d959a 编辑于 作者: drew stachon's avatar drew stachon 提交者: GitLab
浏览文件

Delay writes from redundant pipeline service

上级 e1503697
No related branches found
No related tags found
无相关合并请求
......@@ -25,7 +25,11 @@ def execute
return if pipeline.parent_pipeline? # skip if child pipeline
return unless project.auto_cancel_pending_pipelines?
auto_cancel_all_pipelines_with_cancelable_statuses
cancelable_pipelines.each do |cancelable_pipe|
configured_cancellation_for(cancelable_pipe)
end
log_cancelable_pipeline_outcomes
end
private
......@@ -49,8 +53,8 @@ def ref_head_sha
end
strong_memoize_attr :ref_head_sha
def auto_cancel_all_pipelines_with_cancelable_statuses
cancelable_status_pipeline_pks.each_slice(PK_BATCH_SIZE) do |pks_batch|
def cancelable_pipelines
cancelable_status_pipeline_pks.each_slice(PK_BATCH_SIZE).with_object([]) do |pks_batch, cancelables|
Ci::Pipeline.primary_key_in(pks_batch).order_id_asc.each do |cancelable|
case cancelable.source.to_sym
when *Enums::Ci::Pipeline.ci_sources.keys
......@@ -74,24 +78,11 @@ def auto_cancel_all_pipelines_with_cancelable_statuses
next
end
# Cancel method based on configured strategy
configured_cancellation_for(cancelable)
# Keep the actual Pipeline instantiated
# so we can cancel it directly.
cancelables << cancelable
end
end
Gitlab::AppLogger.info(
class: self.class.name,
message: "Canceling redundant pipelines",
cancellable_count: cancelable_status_pipeline_pks.count,
skipped_for_old_age: @skipped_for_old_age,
conservatively_cancelled: @conservatively_cancelled,
aggressively_cancelled: @aggressively_cancelled,
configured_to_not_cancel: @configured_to_not_cancel,
canceled_by_pipeline_id: pipeline.id,
project_id: pipeline.project_id,
ref: pipeline.ref,
sha: pipeline.sha
)
end
def configured_cancellation_for(cancelable)
......@@ -143,6 +134,22 @@ def cancel_pipeline(cancelable_pipeline, safe_cancellation:)
).force_execute
end
def log_cancelable_pipeline_outcomes
Gitlab::AppLogger.info(
class: self.class.name,
message: "Canceling redundant pipelines",
cancellable_count: cancelable_status_pipeline_pks.count,
skipped_for_old_age: @skipped_for_old_age,
conservatively_cancelled: @conservatively_cancelled,
aggressively_cancelled: @aggressively_cancelled,
configured_to_not_cancel: @configured_to_not_cancel,
canceled_by_pipeline_id: pipeline.id,
project_id: pipeline.project_id,
ref: pipeline.ref,
sha: pipeline.sha
)
end
def pipelines_created_after
7.days.ago
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册