Skip to content
Snippets Groups Projects

Add structured error parsing for user_cherry_pick

Merged John Cai requested to merge jc-structured-errors-for-cherry-pick into master
All threads resolved!
4 files
+ 91
8
Compare changes
  • Side-by-side
  • Inline
Files
4
  • 7dc4e2f9
    Gitaly's UserCherryPick RPC will begin to return structured errors. The
    reason is that currently we return an error message embedded in the
    response and hence it looks like the RPC succeeded. This not only hides
    errors in the metrics and logs, Praefect will also expect transaction
    voting to happen correctly for successful requests. However, an error
    happened which sometimes causes voting to not happen at all. In this
    situation, Praefect will schedule unneeded replication jobs.
    
    This change prepares for the Gitaly change by putting in place code that
    parses the structured error and raises the same errors as it did when
    parsing the response for the analagous errors.
    
    Changelog: changed
@@ -464,6 +464,21 @@ def call_cherry_pick_or_revert(rpc, user:, commit:, branch_name:, message:, star
@@ -464,6 +464,21 @@ def call_cherry_pick_or_revert(rpc, user:, commit:, branch_name:, message:, star
)
)
handle_cherry_pick_or_revert_response(response)
handle_cherry_pick_or_revert_response(response)
 
rescue GRPC::BadStatus => e
 
detailed_error = decode_detailed_error(e)
 
 
case detailed_error&.error
 
when :access_check
 
access_check_error = detailed_error.access_check
 
# These messages were returned from internal/allowed API calls
 
raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message)
 
when :cherry_pick_conflict
 
raise Gitlab::Git::Repository::CreateTreeError, "index conflict"
 
when :target_branch_diverged
 
raise Gitlab::Git::CommitError, "branch diverged"
 
else
 
raise e
 
end
end
end
def handle_cherry_pick_or_revert_response(response)
def handle_cherry_pick_or_revert_response(response)
Loading