Improve error handling of squash and rebase
Previously all Git-related exceptions in squash and rebase would quietly
go to git_json.log
, but these messages should really be tracked in
Sentry and/or exceptions_json.log
.
In addition, if the squash in progress check failed, the merge would get stuck. This commit now handles that error gracefully and logs it.
In the future, we can likely remove git_json.log
altogether.
Example Sentry event: https://sentry.gitlab.net/gitlab/gitlab-geo-internal-develop-is/issues/1568154
Example exceptions_json.log
entry:
{
"severity": "ERROR",
"time": "2020-05-03T14:13:31.532Z",
"correlation_id": "CmckYJXVhd7",
"extra.server": {
"os": {
"name": "Darwin",
"version": "Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64",
"build": "19.4.0",
"kernel_version": "Darwin MacBook-Pro-3.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64"
},
"runtime": {
"name": "ruby",
"version": "ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]"
}
},
"extra.sidekiq": {
"class": "MergeWorker",
"args": [
3218,
1,
{
"should_remove_source_branch": true,
"commit_message": "Merge branch 'squash-test1' into 'master'\n\nUpdate README\n\nSee merge request gnuwget/wget2!2",
"squash_commit_message": "Update README",
"sha": "979d57f11fe6a1fa5e0aed3942ffe896e26fa382"
}
],
"retry": 3,
"queue": "merge",
"backtrace": true,
"jid": "4715d5fa21d5f4ae1c4397da",
"created_at": 1588515210.539402,
"meta.user": "root",
"meta.project": "gnuwget/wget2",
"meta.root_namespace": "gnuwget",
"meta.subscription_plan": "default",
"meta.caller_id": "Projects::MergeRequestsController#merge",
"correlation_id": "CmckYJXVhd7",
"uber-trace-id": "********",
"enqueued_at": 1588515210.5473962
},
"extra.class": "MergeRequests::SquashService",
"extra.message": "Failed to squash merge request",
"extra.merge_request_id": 3218,
"extra.merge_request": "gnuwget/wget2!2",
"extra.save_message_on_model": false,
"extra.current_user_id": 1,
"extra.current_username": "root",
"exception.class": "Gitlab::Git::Repository::GitError",
"exception.message": "test squash failure",
"exception.backtrace": [
"lib/gitlab/gitaly_client/operation_service.rb:271:in `user_squash'",
"lib/gitlab/git/repository.rb:855:in `block in squash'",
"lib/gitlab/git/wraps_gitaly_errors.rb:7:in `wrapped_gitaly_errors'",
"lib/gitlab/git/repository.rb:854:in `squash'",
"app/models/repository.rb:1064:in `squash'",
"app/services/merge_requests/squash_service.rb:26:in `squash!'",
"app/services/merge_requests/squash_service.rb:18:in `execute'",
"app/services/merge_requests/merge_base_service.rb:64:in `squash_sha!'",
"app/services/merge_requests/merge_base_service.rb:24:in `block in source'",
"lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'",
"app/services/merge_requests/merge_base_service.rb:22:in `source'",
"app/services/merge_requests/merge_base_service.rb:34:in `check_source'",
"app/services/merge_requests/merge_service.rb:52:in `error_check!'",
"app/services/merge_requests/merge_service.rb:39:in `validate!'",
"app/services/merge_requests/merge_service.rb:21:in `execute'",
"app/services/merge_requests/merge_service.rb:15:in `execute'",
"app/workers/merge_worker.rb:16:in `perform'",
"lib/gitlab/with_request_store.rb:17:in `enabling_request_store'",
"lib/gitlab/with_request_store.rb:10:in `with_request_store'",
"lib/gitlab/sidekiq_daemon/monitor.rb:49:in `within_job'"
]
}
Edited by Stan Hu