diff options
author | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2022-10-31 20:03:28 +0300 |
---|---|---|
committer | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2022-10-31 20:21:11 +0300 |
commit | fe3f065666a393561a6a6a4b0a32df914b017918 (patch) | |
tree | 06fe6190efc2fce2048b8af71b267b0158be5482 /ruby | |
parent | 443964112b728193ac2796debcf5477826bc7876 (diff) |
ruby: Remove RuggedInterceptor
RuggedInterceptor was used to initialize some data when ruby sidecar
starts to handle a gRPC request. Those data were used in Gitlab's
repository wrapper around Rugged. That wrapper was removed which made
this interceptor redundant.
Changelog: other
Diffstat (limited to 'ruby')
-rwxr-xr-x | ruby/bin/gitaly-ruby | 2 | ||||
-rw-r--r-- | ruby/lib/gitaly_server/rugged_interceptor.rb | 27 | ||||
-rw-r--r-- | ruby/spec/lib/gitaly_server/rugged_interceptor_spec.rb | 38 |
3 files changed, 0 insertions, 67 deletions
diff --git a/ruby/bin/gitaly-ruby b/ruby/bin/gitaly-ruby index 5b5f537a6..11cfa231b 100755 --- a/ruby/bin/gitaly-ruby +++ b/ruby/bin/gitaly-ruby @@ -20,7 +20,6 @@ require 'rugged' require_relative '../lib/gitaly_server.rb' require_relative '../lib/gitaly_server/sentry_interceptor.rb' require_relative '../lib/gitaly_server/exception_sanitizer_interceptor.rb' -require_relative '../lib/gitaly_server/rugged_interceptor.rb' SHUTDOWN_TIMEOUT = 600 @@ -132,7 +131,6 @@ def build_server_interceptor_chain chain << GitalyServer::SentryInterceptor.new chain << Labkit::Tracing::GRPC::ServerInterceptor.new if Labkit::Tracing.enabled? chain << GitalyServer::ExceptionSanitizerInterceptor.new - chain << GitalyServer::RuggedInterceptor.new chain end diff --git a/ruby/lib/gitaly_server/rugged_interceptor.rb b/ruby/lib/gitaly_server/rugged_interceptor.rb deleted file mode 100644 index 72af71f11..000000000 --- a/ruby/lib/gitaly_server/rugged_interceptor.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'grpc' - -module GitalyServer - class RuggedInterceptor < GRPC::ServerInterceptor - # Intercept a unary request response call - %i[request_response server_streamer client_streamer bidi_streamer].each do |meth| - define_method(meth) do |**, &blk| - init_rugged_reference_list - - blk.call - - cleanup_rugged_references - end - end - - def init_rugged_reference_list - Thread.current[::Gitlab::Git::Repository::RUGGED_KEY] = [] - end - - def cleanup_rugged_references - repos = Thread.current[::Gitlab::Git::Repository::RUGGED_KEY] - repos.compact.map(&:close) - end - end -end diff --git a/ruby/spec/lib/gitaly_server/rugged_interceptor_spec.rb b/ruby/spec/lib/gitaly_server/rugged_interceptor_spec.rb deleted file mode 100644 index 879ba1bae..000000000 --- a/ruby/spec/lib/gitaly_server/rugged_interceptor_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -require_relative '../../../lib/gitaly_server/rugged_interceptor.rb' - -describe GitalyServer::RuggedInterceptor do - include TestRepo - - let(:meth) { GitalyServer::RepositoryService.instance_method(:find_license) } - let(:call) { double(metadata: {}) } - - subject do - described_class.new.server_streamer(call: call, method: meth) {} - end - - context 'no Rugged repositories initialized' do - it 'does not clean up any repositories' do - expect(Rugged::Repository).not_to receive(:new) - - subject - end - end - - context 'Rugged repository initialized' do - let(:rugged) { rugged_from_gitaly(test_repo_read_only) } - - let(:streamer) do - described_class.new.server_streamer(call: call, method: meth) do - Thread.current[Gitlab::Git::Repository::RUGGED_KEY] = [rugged] - end - end - - it 'cleans up repositories' do - expect(rugged).to receive(:close).and_call_original - - streamer - end - end -end |