Merge branch 'issue_50528' into 'master'
Log project services sidekiq failures Closes #50528 See merge request gitlab-org/gitlab-ce!21336
This commit is contained in:
commit
8f5c953149
3 changed files with 35 additions and 1 deletions
|
@ -7,6 +7,10 @@ class ProjectServiceWorker
|
|||
|
||||
def perform(hook_id, data)
|
||||
data = data.with_indifferent_access
|
||||
Service.find(hook_id).execute(data)
|
||||
service = Service.find(hook_id)
|
||||
service.execute(data)
|
||||
rescue => error
|
||||
service_class = service&.class&.name || "Not Found"
|
||||
logger.error class: self.class.name, service_class: service_class, message: error.message
|
||||
end
|
||||
end
|
||||
|
|
5
changelogs/unreleased/issue_50528.yml
Normal file
5
changelogs/unreleased/issue_50528.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Log project services errors when executing async
|
||||
merge_request:
|
||||
author:
|
||||
type: other
|
25
spec/workers/project_service_worker_spec.rb
Normal file
25
spec/workers/project_service_worker_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
require 'spec_helper'
|
||||
|
||||
describe ProjectServiceWorker, '#perform' do
|
||||
let(:worker) { described_class.new }
|
||||
let(:service) { JiraService.new }
|
||||
|
||||
before do
|
||||
allow(Service).to receive(:find).and_return(service)
|
||||
end
|
||||
|
||||
it 'executes service with given data' do
|
||||
data = { test: 'test' }
|
||||
expect(service).to receive(:execute).with(data)
|
||||
|
||||
worker.perform(1, data)
|
||||
end
|
||||
|
||||
it 'logs error messages' do
|
||||
allow(service).to receive(:execute).and_raise(StandardError, 'invalid URL')
|
||||
expect(Sidekiq.logger).to receive(:error).with({ class: described_class.name, service_class: service.class.name, message: "invalid URL" })
|
||||
|
||||
worker.perform(1, {})
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue