diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 15:08:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 15:08:16 +0000 |
commit | fb73ca3398c2ac49a616ab553e117b0586089702 (patch) | |
tree | c2f787ac97df38569c59cd0e967331ec1ead6d7e /lib/gitlab | |
parent | b6b8f7dc871e73f29af55f06a773136a7242df57 (diff) | |
download | gitlab-ce-fb73ca3398c2ac49a616ab553e117b0586089702.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/backtrace_cleaner.rb | 36 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/exception_log_formatter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git/rugged_impl/use_rugged.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/profiler.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/repo_path.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/repository_cache.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/repository_set_cache.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/sidekiq_logging/exception_handler.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/workhorse.rb | 8 |
11 files changed, 55 insertions, 24 deletions
diff --git a/lib/gitlab/backtrace_cleaner.rb b/lib/gitlab/backtrace_cleaner.rb new file mode 100644 index 00000000000..30ec99808f7 --- /dev/null +++ b/lib/gitlab/backtrace_cleaner.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Gitlab + module BacktraceCleaner + IGNORE_BACKTRACES = %w[ + config/initializers + ee/lib/gitlab/middleware/ + lib/gitlab/correlation_id.rb + lib/gitlab/database/load_balancing/ + lib/gitlab/etag_caching/ + lib/gitlab/i18n.rb + lib/gitlab/metrics/ + lib/gitlab/middleware/ + lib/gitlab/performance_bar/ + lib/gitlab/profiler.rb + lib/gitlab/query_limiting/ + lib/gitlab/request_context.rb + lib/gitlab/request_profiler/ + lib/gitlab/sidekiq_logging/ + lib/gitlab/sidekiq_middleware/ + lib/gitlab/sidekiq_status/ + lib/gitlab/tracing/ + lib/gitlab/webpack/dev_server_middleware.rb + ].freeze + + IGNORED_BACKTRACES_REGEXP = Regexp.union(IGNORE_BACKTRACES).freeze + + def self.clean_backtrace(backtrace) + return unless backtrace + + Array(Rails.backtrace_cleaner.clean(backtrace)).reject do |line| + line.match(IGNORED_BACKTRACES_REGEXP) + end + end + end +end diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 67118aed549..349ca26ec03 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -42,7 +42,7 @@ module Gitlab end def store_pull_request_error(pull_request, ex) - backtrace = Gitlab::Profiler.clean_backtrace(ex.backtrace) + backtrace = Gitlab::BacktraceCleaner.clean_backtrace(ex.backtrace) error = { type: :pull_request, iid: pull_request.iid, errors: ex.message, trace: backtrace, raw_response: pull_request.raw } Gitlab::ErrorTracking.log_exception(ex, error) diff --git a/lib/gitlab/exception_log_formatter.rb b/lib/gitlab/exception_log_formatter.rb index e0de0219294..92d55213cc2 100644 --- a/lib/gitlab/exception_log_formatter.rb +++ b/lib/gitlab/exception_log_formatter.rb @@ -13,7 +13,7 @@ module Gitlab ) if exception.backtrace - payload['exception.backtrace'] = Gitlab::Profiler.clean_backtrace(exception.backtrace) + payload['exception.backtrace'] = Gitlab::BacktraceCleaner.clean_backtrace(exception.backtrace) end end end diff --git a/lib/gitlab/git/rugged_impl/use_rugged.rb b/lib/gitlab/git/rugged_impl/use_rugged.rb index 80b75689334..ca5d533bd75 100644 --- a/lib/gitlab/git/rugged_impl/use_rugged.rb +++ b/lib/gitlab/git/rugged_impl/use_rugged.rb @@ -27,7 +27,7 @@ module Gitlab feature: method_name, args: args, duration: duration, - backtrace: Gitlab::Profiler.clean_backtrace(caller)) + backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller)) end result diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 25785089a34..9636e75aba1 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -179,7 +179,7 @@ module Gitlab self.query_time += duration if Gitlab::PerformanceBar.enabled_for_request? add_call_details(feature: "#{service}##{rpc}", duration: duration, request: request_hash, rpc: rpc, - backtrace: Gitlab::Profiler.clean_backtrace(caller)) + backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller)) end end @@ -438,7 +438,7 @@ module Gitlab def self.count_stack return unless Gitlab::SafeRequestStore.active? - stack_string = Gitlab::Profiler.clean_backtrace(caller).drop(1).join("\n") + stack_string = Gitlab::BacktraceCleaner.clean_backtrace(caller).drop(1).join("\n") Gitlab::SafeRequestStore[:stack_counter] ||= Hash.new diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index f2f6180c464..f47ccb8fed9 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -107,7 +107,7 @@ module Gitlab super - Gitlab::Profiler.clean_backtrace(caller).each do |caller_line| + Gitlab::BacktraceCleaner.clean_backtrace(caller).each do |caller_line| stripped_caller_line = caller_line.sub("#{Rails.root}/", '') super(" ↳ #{stripped_caller_line}") @@ -117,14 +117,6 @@ module Gitlab end end - def self.clean_backtrace(backtrace) - return unless backtrace - - Array(Rails.backtrace_cleaner.clean(backtrace)).reject do |line| - line.match(Regexp.union(IGNORE_BACKTRACES)) - end - end - def self.with_custom_logger(logger) original_colorize_logging = ActiveSupport::LogSubscriber.colorize_logging original_activerecord_logger = ActiveRecord::Base.logger diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb index 030e50dfbf6..1baa2a9e461 100644 --- a/lib/gitlab/repo_path.rb +++ b/lib/gitlab/repo_path.rb @@ -32,9 +32,12 @@ module Gitlab def self.find_project(project_path) project = Project.find_by_full_path(project_path, follow_redirects: true) - was_redirected = project && project.full_path.casecmp(project_path) != 0 - [project, was_redirected] + [project, redirected?(project, project_path)] + end + + def self.redirected?(project, project_path) + project && project.full_path.casecmp(project_path) != 0 end end end diff --git a/lib/gitlab/repository_cache.rb b/lib/gitlab/repository_cache.rb index 56007574b1b..fca8c43da2e 100644 --- a/lib/gitlab/repository_cache.rb +++ b/lib/gitlab/repository_cache.rb @@ -7,7 +7,8 @@ module Gitlab def initialize(repository, extra_namespace: nil, backend: Rails.cache) @repository = repository - @namespace = "#{repository.full_path}:#{repository.project.id}" + @namespace = "#{repository.full_path}" + @namespace += ":#{repository.project.id}" if repository.project @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @backend = backend end diff --git a/lib/gitlab/repository_set_cache.rb b/lib/gitlab/repository_set_cache.rb index 6d3ac53a787..4797ec0b116 100644 --- a/lib/gitlab/repository_set_cache.rb +++ b/lib/gitlab/repository_set_cache.rb @@ -7,7 +7,8 @@ module Gitlab def initialize(repository, extra_namespace: nil, expires_in: 2.weeks) @repository = repository - @namespace = "#{repository.full_path}:#{repository.project.id}" + @namespace = "#{repository.full_path}" + @namespace += ":#{repository.project.id}" if repository.project @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @expires_in = expires_in end diff --git a/lib/gitlab/sidekiq_logging/exception_handler.rb b/lib/gitlab/sidekiq_logging/exception_handler.rb index fba74b6c9ed..a6d6819bf8e 100644 --- a/lib/gitlab/sidekiq_logging/exception_handler.rb +++ b/lib/gitlab/sidekiq_logging/exception_handler.rb @@ -18,7 +18,7 @@ module Gitlab data.merge!(job_data) if job_data.present? end - data[:error_backtrace] = Gitlab::Profiler.clean_backtrace(job_exception.backtrace) if job_exception.backtrace.present? + data[:error_backtrace] = Gitlab::BacktraceCleaner.clean_backtrace(job_exception.backtrace) if job_exception.backtrace.present? Sidekiq.logger.warn(data) end diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 713ca31bbc5..29450a33289 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -22,18 +22,16 @@ module Gitlab def git_http_ok(repository, repo_type, user, action, show_all_refs: false) raise "Unsupported action: #{action}" unless ALLOWED_GIT_HTTP_ACTIONS.include?(action.to_s) - project = repository.project - attrs = { GL_ID: Gitlab::GlId.gl_id(user), - GL_REPOSITORY: repo_type.identifier_for_subject(project), + GL_REPOSITORY: repo_type.identifier_for_subject(repository.project), GL_USERNAME: user&.username, ShowAllRefs: show_all_refs, Repository: repository.gitaly_repository.to_h, GitConfigOptions: [], GitalyServer: { - address: Gitlab::GitalyClient.address(project.repository_storage), - token: Gitlab::GitalyClient.token(project.repository_storage), + address: Gitlab::GitalyClient.address(repository.storage), + token: Gitlab::GitalyClient.token(repository.storage), features: Feature::Gitaly.server_feature_flags } } |