Distinguish message-size overflow from Gitaly exhaustion

What does this MR do and why?

This MR makes GitLab show a non-retryable message when Gitaly returns a gRPC message-size overflow.

Today, a GRPC::ResourceExhausted from Received message larger than max (<N> vs. 4194304) falls through the generic RESOURCE_EXHAUSTED branch and is shown as Upstream Gitaly has been exhausted. Try again later. That is misleading because the gRPC max-message-size cap is a permanent size limit, not a transient Gitaly capacity problem.

This change:

  • detects the stable gRPC message substring, message larger than max, case-insensitively
  • keeps the same error class, Gitlab::Git::ResourceExhaustedError
  • keeps the same HTTP status, 503
  • keeps the same empty headers, with no Retry-After
  • changes only the message for the message-size overflow case

The retryable Gitaly::LimitError path is unchanged.

🛠️ with ❤️ at Siemens

References

Related to #362327 (closed)

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

Use Rails console to seed the wrapped gRPC error that Gitaly emits when a response is larger than the 4 MiB receive limit.

  1. Seed the message-size overflow condition:

    wrapper = Class.new { include Gitlab::Git::WrapsGitalyErrors }.new
    
    begin
      wrapper.wrapped_gitaly_errors do
        raise GRPC::ResourceExhausted,
          'grpc: Received message larger than max (5691745 vs. 4194304)'
      end
    rescue Gitlab::Git::ResourceExhaustedError => error
      puts error.class.name
      puts error.message
      puts error.headers.inspect
    end

    Expected output:

    Gitlab::Git::ResourceExhaustedError
    The response from Gitaly is too large to load. Maybe, the repository or merge request contains too many commits. This is a size limit, not a temporary error.
    {}
  2. Confirm the generic no-detail RESOURCE_EXHAUSTED case still uses the existing retry message:

    begin
      wrapper.wrapped_gitaly_errors do
        raise GRPC::ResourceExhausted
      end
    rescue Gitlab::Git::ResourceExhaustedError => error
      puts error.message
      puts error.headers.inspect
    end

    Expected output:

    Upstream Gitaly has been exhausted. Try again later
    {}

Validation

  • bundle exec rspec spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb, 13 examples, 0 failures

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Gerardo Navarro

Merge request reports

Loading
Loading