Class: CreatePipelineWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, PipelineQueue
Defined in:
app/workers/create_pipeline_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#log_pipeline_errors(error_message, project, **creation_params) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/workers/create_pipeline_worker.rb', line 36

def log_pipeline_errors(error_message, project, **creation_params)
  data = {
    class: self.class.name,
    correlation_id: Labkit::Correlation::CorrelationId.current_id.to_s,
    project_id: project.id,
    project_path: project.full_path,
    message: "Error creating pipeline",
    errors: error_message,
    pipeline_params: sanitized_pipeline_params(**creation_params)
  }

  Sidekiq.logger.warn(data)
end

#perform(project_id, user_id, ref, source, execute_options = {}, creation_params = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/create_pipeline_worker.rb', line 17

def perform(project_id, user_id, ref, source, execute_options = {}, creation_params = {})
  Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/464671')

  project = Project.find_by_id(project_id)
  return unless project

  user = User.find_by_id(user_id)
  return unless user

  execute_options = execute_options.deep_symbolize_keys
  creation_params = creation_params.symbolize_keys.merge(ref: ref)

  response = Ci::CreatePipelineService
    .new(project, user, **creation_params)
    .execute(source, **execute_options)

  log_pipeline_errors(response.message, project, **creation_params) if response.error?
end

#sanitized_pipeline_params(**creation_params) ⇒ Object



50
51
52
# File 'app/workers/create_pipeline_worker.rb', line 50

def sanitized_pipeline_params(**creation_params)
  creation_params.except(:push_options, :pipeline_creation_request)
end