Commit 7b8b9276 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'log-scheduled-pipeline-creation-failures' into 'master'

Log scheduled pipeline creation failure

See merge request gitlab-org/gitlab!70601
parents a710bb29 836a7e86
......@@ -27,8 +27,9 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
user,
ref: schedule.ref)
.execute!(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: schedule)
rescue Ci::CreatePipelineService::CreateError
# no-op. This is a user operation error such as corrupted .gitlab-ci.yml.
rescue Ci::CreatePipelineService::CreateError => e
# This is a user operation error such as corrupted .gitlab-ci.yml. Log the error for debugging purpose.
log_extra_metadata_on_done(:pipeline_creation_error, e)
rescue StandardError => e
error(schedule, e)
end
......@@ -37,10 +38,16 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
def error(schedule, error)
failed_creation_counter.increment
log_error(schedule, error)
track_error(schedule, error)
end
def log_error(schedule, error)
Gitlab::AppLogger.error "Failed to create a scheduled pipeline. " \
"schedule_id: #{schedule.id} message: #{error.message}"
end
def track_error(schedule, error)
Gitlab::ErrorTracking
.track_and_raise_for_dev_exception(error,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231',
......
......@@ -68,5 +68,20 @@ RSpec.describe RunPipelineScheduleWorker do
worker.perform(pipeline_schedule.id, user.id)
end
end
context 'when pipeline cannot be created' do
before do
allow(Ci::CreatePipelineService).to receive(:new) { raise Ci::CreatePipelineService::CreateError }
end
it 'logging a pipeline error' do
expect(worker)
.to receive(:log_extra_metadata_on_done)
.with(:pipeline_creation_error, an_instance_of(Ci::CreatePipelineService::CreateError))
.and_call_original
worker.perform(pipeline_schedule.id, user.id)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment