Commit 190ea021 authored by Sean McGivern's avatar Sean McGivern

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

Add logs for monitoring the merge process

See merge request gitlab-org/gitlab-ce!15425
parents bd026b6a fad11dec
...@@ -10,6 +10,8 @@ module MergeRequests ...@@ -10,6 +10,8 @@ module MergeRequests
attr_reader :merge_request, :source attr_reader :merge_request, :source
delegate :merge_jid, :state, to: :@merge_request
def execute(merge_request) def execute(merge_request)
if project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService) if project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService)
FfMergeService.new(project, current_user, params).execute(merge_request) FfMergeService.new(project, current_user, params).execute(merge_request)
...@@ -27,6 +29,7 @@ module MergeRequests ...@@ -27,6 +29,7 @@ module MergeRequests
success success
end end
end end
log_info("Merge process finished on JID #{merge_jid} with state #{state}")
rescue MergeError => e rescue MergeError => e
handle_merge_error(log_message: e.message, save_message_on_model: true) handle_merge_error(log_message: e.message, save_message_on_model: true)
end end
...@@ -49,7 +52,9 @@ module MergeRequests ...@@ -49,7 +52,9 @@ module MergeRequests
def commit def commit
message = params[:commit_message] || merge_request.merge_commit_message 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) 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 raise MergeError, 'Conflicts detected during merge' unless commit_id
...@@ -63,7 +68,9 @@ module MergeRequests ...@@ -63,7 +68,9 @@ module MergeRequests
end end
def after_merge def after_merge
log_info("Post merge started on JID #{merge_jid} with state #{state}")
MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) 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? if delete_source_branch?
DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) DeleteBranchService.new(@merge_request.source_project, branch_deletion_user)
...@@ -92,6 +99,11 @@ module MergeRequests ...@@ -92,6 +99,11 @@ module MergeRequests
@merge_request.update(merge_error: log_message) if save_message_on_model @merge_request.update(merge_error: log_message) if save_message_on_model
end end
def log_info(message)
@logger ||= Rails.logger
@logger.info("#{merge_request_info} - #{message}")
end
def merge_request_info def merge_request_info
merge_request.to_reference(full: true) merge_request.to_reference(full: true)
end 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