Commit b94bf73f authored by Sean McGivern's avatar Sean McGivern Committed by Oswaldo Ferreira
Browse files

Merge branch 'osw-merge-process-logs' into 'master'

Add logs for monitoring the merge process

See merge request gitlab-org/gitlab-ce!15425

(cherry picked from commit 190ea021cd1fd89d20c9548a72034a7b941413ca)

76155df4df21 Add logs for monitoring the merge process
73ee2f97818b Add MR reference to logs
parent fdf23ba0fddc
......@@ -10,6 +10,8 @@ class MergeService < MergeRequests::BaseService
attr_reader :merge_request, :source
delegate :merge_jid, :state, to: :@merge_request
def execute(merge_request)
if project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService)
FfMergeService.new(project, current_user, params).execute(merge_request)
......@@ -27,6 +29,7 @@ def execute(merge_request)
success
end
end
log_info("Merge process finished on JID #{merge_jid} with state #{state}")
rescue MergeError => e
handle_merge_error(log_message: e.message, save_message_on_model: true)
end
......@@ -49,7 +52,9 @@ def error_check!
def commit
message = params[:commit_message] || merge_request.merge_commit_message
log_info("Git merge started on JID #{merge_jid}")
commit_id = repository.merge(current_user, source, merge_request, message)
log_info("Git merge finished on JID #{merge_jid} commit #{commit_id}")
raise MergeError, 'Conflicts detected during merge' unless commit_id
......@@ -63,7 +68,9 @@ def commit
end
def after_merge
log_info("Post merge started on JID #{merge_jid} with state #{state}")
MergeRequests::PostMergeService.new(project, current_user).execute(merge_request)
log_info("Post merge finished on JID #{merge_jid} with state #{state}")
if delete_source_branch?
DeleteBranchService.new(@merge_request.source_project, branch_deletion_user)
......@@ -92,6 +99,11 @@ def handle_merge_error(log_message:, save_message_on_model: false)
@merge_request.update(merge_error: log_message) if save_message_on_model
end
def log_info(message)
@logger ||= Rails.logger
@logger.info("#{merge_request_info} - #{message}")
end
def merge_request_info
merge_request.to_reference(full: true)
end
......
---
title: Add logs for monitoring the merge process
merge_request:
author:
type: other
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