Commit bcb8e104 authored by Mayra Cabrera's avatar Mayra Cabrera Committed by Stan Hu

Add a rubocop for Rails.logger

Suggests to use a JSON structured log instead

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/54102
parent fd4c19ed
...@@ -12,6 +12,6 @@ class ChatTeam < ApplicationRecord ...@@ -12,6 +12,6 @@ class ChatTeam < ApplicationRecord
# Either the group is not found, or the user doesn't have the proper # Either the group is not found, or the user doesn't have the proper
# access on the mattermost instance. In the first case, we're done either way # access on the mattermost instance. In the first case, we're done either way
# in the latter case, we can't recover by retrying, so we just log what happened # in the latter case, we can't recover by retrying, so we just log what happened
Rails.logger.error("Mattermost team deletion failed: #{e}") Rails.logger.error("Mattermost team deletion failed: #{e}") # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -266,7 +266,7 @@ module Ci ...@@ -266,7 +266,7 @@ module Ci
begin begin
Ci::Build.retry(build, build.user) Ci::Build.retry(build, build.user)
rescue Gitlab::Access::AccessDeniedError => ex rescue Gitlab::Access::AccessDeniedError => ex
Rails.logger.error "Unable to auto-retry job #{build.id}: #{ex}" Rails.logger.error "Unable to auto-retry job #{build.id}: #{ex}" # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -49,7 +49,7 @@ module CacheableAttributes ...@@ -49,7 +49,7 @@ module CacheableAttributes
current_without_cache.tap { |current_record| current_record&.cache! } current_without_cache.tap { |current_record| current_record&.cache! }
rescue => e rescue => e
if Rails.env.production? if Rails.env.production?
Rails.logger.warn("Cached record for #{name} couldn't be loaded, falling back to uncached record: #{e}") Rails.logger.warn("Cached record for #{name} couldn't be loaded, falling back to uncached record: #{e}") # rubocop:disable Gitlab/RailsLogger
else else
raise e raise e
end end
......
...@@ -64,7 +64,7 @@ module Storage ...@@ -64,7 +64,7 @@ module Storage
unless gitlab_shell.mv_namespace(repository_storage, full_path_before_last_save, full_path) unless gitlab_shell.mv_namespace(repository_storage, full_path_before_last_save, full_path)
Rails.logger.error "Exception moving path #{repository_storage} from #{full_path_before_last_save} to #{full_path}" Rails.logger.error "Exception moving path #{repository_storage} from #{full_path_before_last_save} to #{full_path}" # rubocop:disable Gitlab/RailsLogger
# if we cannot move namespace directory we should rollback # if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs # db changes in order to prevent out of sync between db and fs
......
...@@ -784,6 +784,7 @@ class Project < ApplicationRecord ...@@ -784,6 +784,7 @@ class Project < ApplicationRecord
job_id job_id
end end
# rubocop:disable Gitlab/RailsLogger
def log_import_activity(job_id, type: :import) def log_import_activity(job_id, type: :import)
job_type = type.to_s.capitalize job_type = type.to_s.capitalize
...@@ -793,6 +794,7 @@ class Project < ApplicationRecord ...@@ -793,6 +794,7 @@ class Project < ApplicationRecord
Rails.logger.error("#{job_type} job failed to create for #{full_path}.") Rails.logger.error("#{job_type} job failed to create for #{full_path}.")
end end
end end
# rubocop:enable Gitlab/RailsLogger
def reset_cache_and_import_attrs def reset_cache_and_import_attrs
run_after_commit do run_after_commit do
...@@ -1665,6 +1667,7 @@ class Project < ApplicationRecord ...@@ -1665,6 +1667,7 @@ class Project < ApplicationRecord
end end
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
# rubocop:disable Gitlab/RailsLogger
def write_repository_config(gl_full_path: full_path) def write_repository_config(gl_full_path: full_path)
# We'd need to keep track of project full path otherwise directory tree # We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using # created with hashed storage enabled cannot be usefully imported using
...@@ -1674,6 +1677,7 @@ class Project < ApplicationRecord ...@@ -1674,6 +1677,7 @@ class Project < ApplicationRecord
Rails.logger.error("Error writing to .git/config for project #{full_path} (#{id}): #{e.message}.") Rails.logger.error("Error writing to .git/config for project #{full_path} (#{id}): #{e.message}.")
nil nil
end end
# rubocop:enable Gitlab/RailsLogger
def after_import def after_import
repository.after_import repository.after_import
...@@ -1715,6 +1719,7 @@ class Project < ApplicationRecord ...@@ -1715,6 +1719,7 @@ class Project < ApplicationRecord
@pipeline_status ||= Gitlab::Cache::Ci::ProjectPipelineStatus.load_for_project(self) @pipeline_status ||= Gitlab::Cache::Ci::ProjectPipelineStatus.load_for_project(self)
end end
# rubocop:disable Gitlab/RailsLogger
def add_export_job(current_user:, after_export_strategy: nil, params: {}) def add_export_job(current_user:, after_export_strategy: nil, params: {})
job_id = ProjectExportWorker.perform_async(current_user.id, self.id, after_export_strategy, params) job_id = ProjectExportWorker.perform_async(current_user.id, self.id, after_export_strategy, params)
...@@ -1724,6 +1729,7 @@ class Project < ApplicationRecord ...@@ -1724,6 +1729,7 @@ class Project < ApplicationRecord
Rails.logger.error "Export job failed to start for project ID #{self.id}" Rails.logger.error "Export job failed to start for project ID #{self.id}"
end end
end end
# rubocop:enable Gitlab/RailsLogger
def import_export_shared def import_export_shared
@import_export_shared ||= Gitlab::ImportExport::Shared.new(self) @import_export_shared ||= Gitlab::ImportExport::Shared.new(self)
......
...@@ -65,7 +65,7 @@ class ProjectImportState < ApplicationRecord ...@@ -65,7 +65,7 @@ class ProjectImportState < ApplicationRecord
update_column(:last_error, sanitized_message) update_column(:last_error, sanitized_message)
rescue ActiveRecord::ActiveRecordError => e rescue ActiveRecord::ActiveRecordError => e
Rails.logger.error("Error setting import status to failed: #{e.message}. Original error: #{sanitized_message}") Rails.logger.error("Error setting import status to failed: #{e.message}. Original error: #{sanitized_message}") # rubocop:disable Gitlab/RailsLogger
ensure ensure
@errors = original_errors @errors = original_errors
end end
......
...@@ -273,7 +273,7 @@ class Repository ...@@ -273,7 +273,7 @@ class Repository
# This will still fail if the file is corrupted (e.g. 0 bytes) # This will still fail if the file is corrupted (e.g. 0 bytes)
raw_repository.write_ref(keep_around_ref_name(sha), sha) raw_repository.write_ref(keep_around_ref_name(sha), sha)
rescue Gitlab::Git::CommandError => ex rescue Gitlab::Git::CommandError => ex
Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -934,6 +934,7 @@ class Repository ...@@ -934,6 +934,7 @@ class Repository
async_remove_remote(remote_name) if tmp_remote_name async_remove_remote(remote_name) if tmp_remote_name
end end
# rubocop:disable Gitlab/RailsLogger
def async_remove_remote(remote_name) def async_remove_remote(remote_name)
return unless remote_name return unless remote_name
...@@ -947,6 +948,7 @@ class Repository ...@@ -947,6 +948,7 @@ class Repository
job_id job_id
end end
# rubocop:enable Gitlab/RailsLogger
def fetch_source_branch!(source_repository, source_branch, local_ref) def fetch_source_branch!(source_repository, source_branch, local_ref)
raw_repository.fetch_source_branch!(source_repository.raw_repository, source_branch, local_ref) raw_repository.fetch_source_branch!(source_repository.raw_repository, source_branch, local_ref)
......
...@@ -106,7 +106,7 @@ class SshHostKey ...@@ -106,7 +106,7 @@ class SshHostKey
if status.success? && !errors.present? if status.success? && !errors.present?
{ known_hosts: known_hosts } { known_hosts: known_hosts }
else else
Rails.logger.debug("Failed to detect SSH host keys for #{id}: #{errors}") Rails.logger.debug("Failed to detect SSH host keys for #{id}: #{errors}") # rubocop:disable Gitlab/RailsLogger
{ error: 'Failed to detect SSH host keys' } { error: 'Failed to detect SSH host keys' }
end end
......
...@@ -41,7 +41,7 @@ module Storage ...@@ -41,7 +41,7 @@ module Storage
gitlab_shell.mv_repository(repository_storage, "#{old_full_path}.wiki", "#{new_full_path}.wiki") gitlab_shell.mv_repository(repository_storage, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
return true return true
rescue => e rescue => e
Rails.logger.error "Exception renaming #{old_full_path} -> #{new_full_path}: #{e}" Rails.logger.error "Exception renaming #{old_full_path} -> #{new_full_path}: #{e}" # rubocop:disable Gitlab/RailsLogger
# Returning false does not rollback after_* transaction but gives # Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks # us information about failing some of tasks
return false return false
......
...@@ -7,7 +7,7 @@ module Uploads ...@@ -7,7 +7,7 @@ module Uploads
attr_reader :logger attr_reader :logger
def initialize(logger: nil) def initialize(logger: nil)
@logger ||= Rails.logger @logger ||= Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
def delete_keys_async(keys_to_delete) def delete_keys_async(keys_to_delete)
......
...@@ -25,7 +25,7 @@ class AkismetService ...@@ -25,7 +25,7 @@ class AkismetService
is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params) is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params)
is_spam || is_blatant is_spam || is_blatant
rescue => e rescue => e
Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") # rubocop:disable Gitlab/RailsLogger
false false
end end
end end
...@@ -63,7 +63,7 @@ class AkismetService ...@@ -63,7 +63,7 @@ class AkismetService
akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend
true true
rescue => e rescue => e
Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") # rubocop:disable Gitlab/RailsLogger
false false
end end
end end
......
...@@ -24,11 +24,11 @@ module Ci ...@@ -24,11 +24,11 @@ module Ci
def archive_error(error, job) def archive_error(error, job)
failed_archive_counter.increment failed_archive_counter.increment
Rails.logger.error "Failed to archive trace. id: #{job.id} message: #{error.message}" Rails.logger.error "Failed to archive trace. id: #{job.id} message: #{error.message}" # rubocop:disable Gitlab/RailsLogger
Gitlab::Sentry Gitlab::Sentry
.track_exception(error, .track_exception(error,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502', issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502',
extra: { job_id: job.id }) extra: { job_id: job.id })
end end
end end
......
...@@ -58,6 +58,6 @@ module ExclusiveLeaseGuard ...@@ -58,6 +58,6 @@ module ExclusiveLeaseGuard
end end
def log_error(message, extra_args = {}) def log_error(message, extra_args = {})
Rails.logger.error(message) Rails.logger.error(message) # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -6,7 +6,7 @@ module Groups ...@@ -6,7 +6,7 @@ module Groups
def async_execute def async_execute
job_id = GroupDestroyWorker.perform_async(group.id, current_user.id) job_id = GroupDestroyWorker.perform_async(group.id, current_user.id)
Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}") Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}") # rubocop:disable Gitlab/RailsLogger
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -20,7 +20,7 @@ module Labels ...@@ -20,7 +20,7 @@ module Labels
label.save label.save
label label
else else
Rails.logger.warn("target_params should contain :project or :group or :template, actual value: #{target_params}") Rails.logger.warn("target_params should contain :project or :group or :template, actual value: #{target_params}") # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -113,12 +113,12 @@ module MergeRequests ...@@ -113,12 +113,12 @@ module MergeRequests
end end
def handle_merge_error(log_message:, save_message_on_model: false) def handle_merge_error(log_message:, save_message_on_model: false)
Rails.logger.error("MergeService ERROR: #{merge_request_info} - #{log_message}") Rails.logger.error("MergeService ERROR: #{merge_request_info} - #{log_message}") # rubocop:disable Gitlab/RailsLogger
@merge_request.update(merge_error: log_message) if save_message_on_model @merge_request.update(merge_error: log_message) if save_message_on_model
end end
def log_info(message) def log_info(message)
@logger ||= Rails.logger @logger ||= Rails.logger # rubocop:disable Gitlab/RailsLogger
@logger.info("#{merge_request_info} - #{message}") @logger.info("#{merge_request_info} - #{message}")
end end
......
...@@ -13,7 +13,7 @@ module Projects ...@@ -13,7 +13,7 @@ module Projects
repository.delete_all_refs_except(RESERVED_REF_PREFIXES) repository.delete_all_refs_except(RESERVED_REF_PREFIXES)
end end
rescue Projects::HousekeepingService::LeaseTaken => e rescue Projects::HousekeepingService::LeaseTaken => e
Rails.logger.info( Rails.logger.info( # rubocop:disable Gitlab/RailsLogger
"Could not perform housekeeping for project #{@project.full_path} (#{@project.id}): #{e}") "Could not perform housekeeping for project #{@project.full_path} (#{@project.id}): #{e}")
end end
......
...@@ -151,7 +151,7 @@ module Projects ...@@ -151,7 +151,7 @@ module Projects
log_message = message.dup log_message = message.dup
log_message << " Project ID: #{@project.id}" if @project&.id log_message << " Project ID: #{@project.id}" if @project&.id
Rails.logger.error(log_message) Rails.logger.error(log_message) # rubocop:disable Gitlab/RailsLogger
if @project && @project.persisted? && @project.import_state if @project && @project.persisted? && @project.import_state
@project.import_state.mark_as_failed(message) @project.import_state.mark_as_failed(message)
......
...@@ -18,7 +18,7 @@ module Projects ...@@ -18,7 +18,7 @@ module Projects
schedule_stale_repos_removal schedule_stale_repos_removal
job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params)
Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.full_path} with job ID #{job_id}") Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.full_path} with job ID #{job_id}") # rubocop:disable Gitlab/RailsLogger
end end
def execute def execute
......
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
class MigrateAttachmentsService < BaseAttachmentService class MigrateAttachmentsService < BaseAttachmentService
def initialize(project, old_disk_path, logger: nil) def initialize(project, old_disk_path, logger: nil)
@project = project @project = project
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
@old_disk_path = old_disk_path @old_disk_path = old_disk_path
@skipped = false @skipped = false
end end
......
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
class RollbackAttachmentsService < BaseAttachmentService class RollbackAttachmentsService < BaseAttachmentService
def initialize(project, logger: nil) def initialize(project, logger: nil)
@project = project @project = project
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
@old_disk_path = project.disk_path @old_disk_path = project.disk_path
end end
......
...@@ -8,7 +8,7 @@ module Projects ...@@ -8,7 +8,7 @@ module Projects
def initialize(project, old_disk_path, logger: nil) def initialize(project, old_disk_path, logger: nil)
@project = project @project = project
@old_disk_path = old_disk_path @old_disk_path = old_disk_path
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
def execute def execute
......
...@@ -62,7 +62,7 @@ module Projects ...@@ -62,7 +62,7 @@ module Projects
end end
def cleanup_and_notify_error def cleanup_and_notify_error
Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{@shared.errors.join(', ')}") Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{@shared.errors.join(', ')}") # rubocop:disable Gitlab/RailsLogger
FileUtils.rm_rf(@shared.export_path) FileUtils.rm_rf(@shared.export_path)
...@@ -76,7 +76,7 @@ module Projects ...@@ -76,7 +76,7 @@ module Projects
end end
def notify_success def notify_success
Rails.logger.info("Import/Export - Project #{project.name} with ID: #{project.id} successfully exported") Rails.logger.info("Import/Export - Project #{project.name} with ID: #{project.id} successfully exported") # rubocop:disable Gitlab/RailsLogger
end end
def notify_error def notify_error
......
...@@ -15,7 +15,7 @@ module Projects ...@@ -15,7 +15,7 @@ module Projects
def propagate def propagate
return unless @template.active? return unless @template.active?
Rails.logger.info("Propagating services for template #{@template.id}") Rails.logger.info("Propagating services for template #{@template.id}") # rubocop:disable Gitlab/RailsLogger
propagate_projects_with_template propagate_projects_with_template
end end
......
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
def execute def execute
return unless project return unless project
Rails.logger.info("Updating statistics for project #{project.id}") Rails.logger.info("Updating statistics for project #{project.id}") # rubocop:disable Gitlab/RailsLogger
project.statistics.refresh!(only: statistics.map(&:to_sym)) project.statistics.refresh!(only: statistics.map(&:to_sym))
end end
......
...@@ -28,7 +28,7 @@ class SubmitUsagePingService ...@@ -28,7 +28,7 @@ class SubmitUsagePingService
true true
rescue Gitlab::HTTP::Error => e rescue Gitlab::HTTP::Error => e
Rails.logger.info "Unable to contact GitLab, Inc.: #{e}" Rails.logger.info "Unable to contact GitLab, Inc.: #{e}" # rubocop:disable Gitlab/RailsLogger
false false
end end
......
...@@ -53,7 +53,7 @@ class WebHookService ...@@ -53,7 +53,7 @@ class WebHookService
error_message: e.to_s error_message: e.to_s
) )
Rails.logger.error("WebHook Error => #{e}") Rails.logger.error("WebHook Error => #{e}") # rubocop:disable Gitlab/RailsLogger
{ {
status: :error, status: :error,
......
...@@ -98,7 +98,7 @@ class FileMover ...@@ -98,7 +98,7 @@ class FileMover
end end
def revert def revert
Rails.logger.warn("Markdown not updated, file move reverted for #{to_model}") Rails.logger.warn("Markdown not updated, file move reverted for #{to_model}") # rubocop:disable Gitlab/RailsLogger
if temp_file_uploader.file_storage? if temp_file_uploader.file_storage?
FileUtils.move(file_path, temp_file_path) FileUtils.move(file_path, temp_file_path)
......
...@@ -27,6 +27,6 @@ module NewIssuable ...@@ -27,6 +27,6 @@ module NewIssuable
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def log_error(record_class, record_id) def log_error(record_class, record_id)
Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -22,7 +22,7 @@ class CreateGpgSignatureWorker ...@@ -22,7 +22,7 @@ class CreateGpgSignatureWorker
commits.each do |commit| commits.each do |commit|
Gitlab::Gpg::Commit.new(commit).signature Gitlab::Gpg::Commit.new(commit).signature
rescue => e rescue => e
Rails.logger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}") Rails.logger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}") # rubocop:disable Gitlab/RailsLogger
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -9,6 +9,6 @@ class DeleteUserWorker ...@@ -9,6 +9,6 @@ class DeleteUserWorker
Users::DestroyService.new(current_user).execute(delete_user, options.symbolize_keys) Users::DestroyService.new(current_user).execute(delete_user, options.symbolize_keys)
rescue Gitlab::Access::AccessDeniedError => e rescue Gitlab::Access::AccessDeniedError => e
Rails.logger.warn("User could not be destroyed: #{e}") Rails.logger.warn("User could not be destroyed: #{e}") # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -16,7 +16,7 @@ class EmailReceiverWorker ...@@ -16,7 +16,7 @@ class EmailReceiverWorker
private private
def handle_failure(raw, error) def handle_failure(raw, error)
Rails.logger.warn("Email can not be processed: #{error}\n\n#{raw}") Rails.logger.warn("Email can not be processed: #{error}\n\n#{raw}") # rubocop:disable Gitlab/RailsLogger
return unless raw.present? return unless raw.present?
......
...@@ -18,7 +18,7 @@ class ExpireBuildArtifactsWorker ...@@ -18,7 +18,7 @@ class ExpireBuildArtifactsWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform_legacy_artifacts_removal def perform_legacy_artifacts_removal
Rails.logger.info 'Scheduling removal of build artifacts' Rails.logger.info 'Scheduling removal of build artifacts' # rubocop:disable Gitlab/RailsLogger
build_ids = Ci::Build.with_expired_artifacts.pluck(:id) build_ids = Ci::Build.with_expired_artifacts.pluck(:id)
build_ids = build_ids.map { |build_id| [build_id] } build_ids = build_ids.map { |build_id| [build_id] }
......
...@@ -12,7 +12,7 @@ class ExpireBuildInstanceArtifactsWorker ...@@ -12,7 +12,7 @@ class ExpireBuildInstanceArtifactsWorker
return unless build&.project && !build.project.pending_delete return unless build&.project && !build.project.pending_delete
Rails.logger.info "Removing artifacts for build #{build.id}..." Rails.logger.info "Removing artifacts for build #{build.id}..." # rubocop:disable Gitlab/RailsLogger
build.erase_erasable_artifacts! build.erase_erasable_artifacts!
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -11,7 +11,7 @@ class NewNoteWorker ...@@ -11,7 +11,7 @@ class NewNoteWorker
NotificationService.new.new_note(note) unless skip_notification?(note) NotificationService.new.new_note(note) unless skip_notification?(note)
Notes::PostProcessService.new(note).execute Notes::PostProcessService.new(note).execute
else else
Rails.logger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job") Rails.logger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job") # rubocop:disable Gitlab/RailsLogger
end end
end end
......
...@@ -37,6 +37,7 @@ module ObjectStorage ...@@ -37,6 +37,7 @@ module ObjectStorage
end end
end end
# rubocop:disable Gitlab/RailsLogger
def report!(results) def report!(results)
success, failures = results.partition(&:success?) success, failures = results.partition(&:success?)
...@@ -45,6 +46,7 @@ module ObjectStorage ...@@ -45,6 +46,7 @@ module ObjectStorage
raise MigrationFailures.new(failures.map(&:error)) if failures.any? raise MigrationFailures.new(failures.map(&:error)) if failures.any?
end end
# rubocop:enable Gitlab/RailsLogger
def header(success, failures) def header(success, failures)
_("Migrated %{success_count}/%{total_count} files.") % { success_count: success.count, total_count: success.count + failures.count } _("Migrated %{success_count}/%{total_count} files.") % { success_count: success.count, total_count: success.count + failures.count }
...@@ -98,7 +100,7 @@ module ObjectStorage ...@@ -98,7 +100,7 @@ module ObjectStorage
report!(results) report!(results)
rescue SanityCheckError => e rescue SanityCheckError => e
# do not retry: the job is insane # do not retry: the job is insane
Rails.logger.warn "#{self.class}: Sanity check error (#{e.message})" Rails.logger.warn "#{self.class}: Sanity check error (#{e.message})" # rubocop:disable Gitlab/RailsLogger
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -35,7 +35,7 @@ class RepositoryForkWorker ...@@ -35,7 +35,7 @@ class RepositoryForkWorker
def start_fork(project) def start_fork(project)
return true if start(project.import_state) return true if start(project.import_state)
Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") # rubocop:disable Gitlab/RailsLogger
false false
end end
end end
...@@ -36,7 +36,7 @@ class RepositoryImportWorker ...@@ -36,7 +36,7 @@ class RepositoryImportWorker
def start_import def start_import
return true if start(project.import_state) return true if start(project.import_state)
Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while importing.") Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while importing.") # rubocop:disable Gitlab/RailsLogger
false false
end end
......
...@@ -45,6 +45,6 @@ class RepositoryUpdateRemoteMirrorWorker ...@@ -45,6 +45,6 @@ class RepositoryUpdateRemoteMirrorWorker
def fail_remote_mirror(remote_mirror, message) def fail_remote_mirror(remote_mirror, message)
remote_mirror.mark_as_failed(message) remote_mirror.mark_as_failed(message)
Rails.logger.error(message) Rails.logger.error(message) # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -30,6 +30,7 @@ class RunPipelineScheduleWorker ...@@ -30,6 +30,7 @@ class RunPipelineScheduleWorker
private private
# rubocop:disable Gitlab/RailsLogger
def error(schedule, error) def error(schedule, error)
failed_creation_counter.increment failed_creation_counter.increment
...@@ -41,6 +42,7 @@ class RunPipelineScheduleWorker ...@@ -41,6 +42,7 @@ class RunPipelineScheduleWorker
issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/41231', issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/41231',
extra: { schedule_id: schedule.id }) extra: { schedule_id: schedule.id })
end end
# rubocop:enable Gitlab/RailsLogger
def failed_creation_counter def failed_creation_counter
@failed_creation_counter ||= @failed_creation_counter ||=
......
...@@ -14,7 +14,7 @@ class StuckCiJobsWorker ...@@ -14,7 +14,7 @@ class StuckCiJobsWorker
def perform def perform
return unless try_obtain_lease return unless try_obtain_lease
Rails.logger.info "#{self.class}: Cleaning stuck builds" Rails.logger.info "#{self.class}: Cleaning stuck builds" # rubocop:disable Gitlab/RailsLogger
drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
...@@ -66,7 +66,7 @@ class StuckCiJobsWorker ...@@ -66,7 +66,7 @@ class StuckCiJobsWorker
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def drop_build(type, build, status, timeout, reason) def drop_build(type, build, status, timeout, reason)
Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})" Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})" # rubocop:disable Gitlab/RailsLogger
Gitlab::OptimisticLocking.retry_lock(build, 3) do |b| Gitlab::OptimisticLocking.retry_lock(build, 3) do |b|
b.drop(reason) b.drop(reason)
end end
......
...@@ -38,7 +38,7 @@ class StuckImportJobsWorker ...@@ -38,7 +38,7 @@ class StuckImportJobsWorker
completed_import_states = enqueued_import_states_with_jid.where(id: completed_import_state_ids) completed_import_states = enqueued_import_states_with_jid.where(id: completed_import_state_ids)
completed_import_state_jids = completed_import_states.map { |import_state| import_state.jid }.join(', ') completed_import_state_jids = completed_import_states.map { |import_state| import_state.jid }.join(', ')
Rails.logger.info("Marked stuck import jobs as failed. JIDs: #{completed_import_state_jids}") Rails.logger.info("Marked stuck import jobs as failed. JIDs: #{completed_import_state_jids}") # rubocop:disable Gitlab/RailsLogger
completed_import_states.each do |import_state| completed_import_states.each do |import_state|
import_state.mark_as_failed(error_message) import_state.mark_as_failed(error_message)
......
...@@ -5,7 +5,7 @@ class StuckMergeJobsWorker ...@@ -5,7 +5,7 @@ class StuckMergeJobsWorker
include CronjobQueue include CronjobQueue
def self.logger def self.logger
Rails.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -5,7 +5,7 @@ class TrendingProjectsWorker ...@@ -5,7 +5,7 @@ class TrendingProjectsWorker
include CronjobQueue include CronjobQueue
def perform def perform
Rails.logger.info('Refreshing trending projects') Rails.logger.info('Refreshing trending projects') # rubocop:disable Gitlab/RailsLogger
TrendingProject.refresh! TrendingProject.refresh!
end end
......
...@@ -27,7 +27,7 @@ class UpdateMergeRequestsWorker ...@@ -27,7 +27,7 @@ class UpdateMergeRequestsWorker
"ref=#{ref}" "ref=#{ref}"
].join(',') ].join(',')
Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD # rubocop:disable Gitlab/RailsLogger
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
...@@ -8,6 +8,6 @@ class UploadChecksumWorker ...@@ -8,6 +8,6 @@ class UploadChecksumWorker
upload.calculate_checksum! upload.calculate_checksum!
upload.save! upload.save!
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
Rails.logger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping") Rails.logger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping") # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -55,7 +55,7 @@ if Settings.ldap['enabled'] || Rails.env.test? ...@@ -55,7 +55,7 @@ if Settings.ldap['enabled'] || Rails.env.test?
server['tls_options'] ||= {} server['tls_options'] ||= {}
if server['ssl_version'] || server['ca_file'] if server['ssl_version'] || server['ca_file']
Rails.logger.warn 'DEPRECATED: LDAP options `ssl_version` and `ca_file` should be nested within `tls_options`' Rails.logger.warn 'DEPRECATED: LDAP options `ssl_version` and `ca_file` should be nested within `tls_options`' # rubocop:disable Gitlab/RailsLogger
end end
if server['ssl_version'] if server['ssl_version']
......
...@@ -17,7 +17,7 @@ def prometheus_default_multiproc_dir ...@@ -17,7 +17,7 @@ def prometheus_default_multiproc_dir
end end
Prometheus::Client.configure do |config| Prometheus::Client.configure do |config|
config.logger = Rails.logger config.logger = Rails.logger # rubocop:disable Gitlab/RailsLogger
config.initial_mmap_file_size = 4 * 1024 config.initial_mmap_file_size = 4 * 1024
......
...@@ -7,7 +7,7 @@ if defined?(ActiveRecord::Base) && !Sidekiq.server? ...@@ -7,7 +7,7 @@ if defined?(ActiveRecord::Base) && !Sidekiq.server?
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection ActiveRecord::Base.establish_connection
Rails.logger.debug("ActiveRecord connection established") Rails.logger.debug("ActiveRecord connection established") # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
...@@ -18,6 +18,6 @@ if defined?(ActiveRecord::Base) ...@@ -18,6 +18,6 @@ if defined?(ActiveRecord::Base)
# as there's no need for the master process to hold a connection # as there's no need for the master process to hold a connection
ActiveRecord::Base.connection.disconnect! ActiveRecord::Base.connection.disconnect!
Rails.logger.debug("ActiveRecord connection disconnected") Rails.logger.debug("ActiveRecord connection disconnected") # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -2,7 +2,7 @@ if Rails.env.development? || ENV['GITLAB_LEGACY_PATH_LOG_MESSAGE'] ...@@ -2,7 +2,7 @@ if Rails.env.development? || ENV['GITLAB_LEGACY_PATH_LOG_MESSAGE']
deprecator = ActiveSupport::Deprecation.new('11.0', 'GitLab') deprecator = ActiveSupport::Deprecation.new('11.0', 'GitLab')
deprecator.behavior = -> (message, callstack) { deprecator.behavior = -> (message, callstack) {
Rails.logger.warn("#{message}: #{callstack[1..20].join}") Rails.logger.warn("#{message}: #{callstack[1..20].join}") # rubocop:disable Gitlab/RailsLogger
} }
ActiveSupport::Deprecation.deprecate_methods(Gitlab::GitalyClient::StorageSettings, :legacy_disk_path, deprecator: deprecator) ActiveSupport::Deprecation.deprecate_methods(Gitlab::GitalyClient::StorageSettings, :legacy_disk_path, deprecator: deprecator)
......
...@@ -72,7 +72,7 @@ Sidekiq.configure_server do |config| ...@@ -72,7 +72,7 @@ Sidekiq.configure_server do |config|
cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') cron_jobs[k]['class'] = cron_jobs[k].delete('job_class')
else else
cron_jobs.delete(k) cron_jobs.delete(k)
Rails.logger.error("Invalid cron_jobs config key: '#{k}'. Check your gitlab config file.") Rails.logger.error("Invalid cron_jobs config key: '#{k}'. Check your gitlab config file.") # rubocop:disable Gitlab/RailsLogger
end end
end end
Sidekiq::Cron::Job.load_from_hash! cron_jobs Sidekiq::Cron::Job.load_from_hash! cron_jobs
...@@ -83,7 +83,7 @@ Sidekiq.configure_server do |config| ...@@ -83,7 +83,7 @@ Sidekiq.configure_server do |config|
Rails.application.config.database_configuration[Rails.env] Rails.application.config.database_configuration[Rails.env]
db_config['pool'] = Sidekiq.options[:concurrency] db_config['pool'] = Sidekiq.options[:concurrency]
ActiveRecord::Base.establish_connection(db_config) ActiveRecord::Base.establish_connection(db_config)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") # rubocop:disable Gitlab/RailsLogger
Gitlab.ee do Gitlab.ee do
Gitlab::Mirror.configure_cron_job! Gitlab::Mirror.configure_cron_job!
...@@ -94,7 +94,7 @@ Sidekiq.configure_server do |config| ...@@ -94,7 +94,7 @@ Sidekiq.configure_server do |config|
Rails.configuration.geo_database['pool'] = Sidekiq.options[:concurrency] Rails.configuration.geo_database['pool'] = Sidekiq.options[:concurrency]
Geo::TrackingBase.establish_connection(Rails.configuration.geo_database) Geo::TrackingBase.establish_connection(Rails.configuration.geo_database)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{Geo::TrackingBase.connection_pool.size} (Geo tracking database)") Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{Geo::TrackingBase.connection_pool.size} (Geo tracking database)") # rubocop:disable Gitlab/RailsLogger
end end
end end
......
post '/api/graphql', to: 'graphql#execute' post '/api/graphql', to: 'graphql#execute'
mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql' mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql'
::API::API.logger Rails.logger ::API::API.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
mount ::API::API => '/' mount ::API::API => '/'
...@@ -82,7 +82,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] ...@@ -82,7 +82,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
iteration = 0 iteration = 0
records = 0 records = 0
begin begin
Rails.logger.info "Building user_interacted_projects table, batch ##{iteration}" Rails.logger.info "Building user_interacted_projects table, batch ##{iteration}" # rubocop:disable Gitlab/RailsLogger
result = execute <<~SQL result = execute <<~SQL
INSERT INTO user_interacted_projects (user_id, project_id) INSERT INTO user_interacted_projects (user_id, project_id)
SELECT e.user_id, e.project_id SELECT e.user_id, e.project_id
...@@ -93,7 +93,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] ...@@ -93,7 +93,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
SQL SQL
iteration += 1 iteration += 1
records += result.cmd_tuples records += result.cmd_tuples
Rails.logger.info "Building user_interacted_projects table, batch ##{iteration} complete, created #{records} overall" Rails.logger.info "Building user_interacted_projects table, batch ##{iteration} complete, created #{records} overall" # rubocop:disable Gitlab/RailsLogger
Kernel.sleep(SLEEP_TIME) if result.cmd_tuples > 0 Kernel.sleep(SLEEP_TIME) if result.cmd_tuples > 0
end while result.cmd_tuples > 0 end while result.cmd_tuples > 0
end end
......
...@@ -82,7 +82,7 @@ module EE ...@@ -82,7 +82,7 @@ module EE
# Return user principal name if authentication succeeded # Return user principal name if authentication succeeded
gss.display_name gss.display_name
rescue GSSAPI::GssApiError => ex rescue GSSAPI::GssApiError => ex
Rails.logger.error "#{self.class.name}: failed to process Negotiate/Kerberos authentication: #{ex.message}" Rails.logger.error "#{self.class.name}: failed to process Negotiate/Kerberos authentication: #{ex.message}" # rubocop:disable Gitlab/RailsLogger
false false
end end
......
...@@ -212,7 +212,7 @@ class GeoNode < ApplicationRecord ...@@ -212,7 +212,7 @@ class GeoNode < ApplicationRecord
# be called in an initializer and we don't want other callbacks # be called in an initializer and we don't want other callbacks
# to mess with uninitialized dependencies. # to mess with uninitialized dependencies.
if clone_url_prefix_changed? if clone_url_prefix_changed?
Rails.logger.info "Geo: modified clone_url_prefix to #{clone_url_prefix}" Rails.logger.info "Geo: modified clone_url_prefix to #{clone_url_prefix}" # rubocop:disable Gitlab/RailsLogger
update_column(:clone_url_prefix, clone_url_prefix) update_column(:clone_url_prefix, clone_url_prefix)
end end
end end
......
...@@ -21,7 +21,7 @@ class FetchSubscriptionPlansService ...@@ -21,7 +21,7 @@ class FetchSubscriptionPlansService
JSON.parse(response.body).map { |plan| Hashie::Mash.new(plan) } JSON.parse(response.body).map { |plan| Hashie::Mash.new(plan) }
rescue => e rescue => e
Rails.logger.info "Unable to connect to GitLab Customers App #{e}" Rails.logger.info "Unable to connect to GitLab Customers App #{e}" # rubocop:disable Gitlab/RailsLogger
nil nil
end end
......
...@@ -5,6 +5,7 @@ class LdapSyncWorker ...@@ -5,6 +5,7 @@ class LdapSyncWorker
include CronjobQueue include CronjobQueue
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable Gitlab/RailsLogger
def perform def perform
return unless Gitlab::Auth::LDAP::Config.group_sync_enabled? return unless Gitlab::Auth::LDAP::Config.group_sync_enabled?
...@@ -17,4 +18,5 @@ class LdapSyncWorker ...@@ -17,4 +18,5 @@ class LdapSyncWorker
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable Gitlab/RailsLogger
end end
...@@ -8,6 +8,6 @@ class ProjectUpdateRepositoryStorageWorker ...@@ -8,6 +8,6 @@ class ProjectUpdateRepositoryStorageWorker
::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key) ::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key)
rescue ::Projects::UpdateRepositoryStorageService::RepositoryAlreadyMoved rescue ::Projects::UpdateRepositoryStorageService::RepositoryAlreadyMoved
Rails.logger.info "#{self.class}: repository already moved: #{project}" Rails.logger.info "#{self.class}: repository already moved: #{project}" # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -16,7 +16,7 @@ class PseudonymizerWorker ...@@ -16,7 +16,7 @@ class PseudonymizerWorker
uploader = Pseudonymizer::Uploader.new(options, progress_output: File.open(File::NULL, "w")) uploader = Pseudonymizer::Uploader.new(options, progress_output: File.open(File::NULL, "w"))
unless uploader.available? unless uploader.available?
Rails.logger.error("The pseudonymizer object storage must be configured.") Rails.logger.error("The pseudonymizer object storage must be configured.") # rubocop:disable Gitlab/RailsLogger
return return
end end
......
...@@ -35,6 +35,7 @@ class RepositoryUpdateMirrorWorker ...@@ -35,6 +35,7 @@ class RepositoryUpdateMirrorWorker
private private
# rubocop:disable Gitlab/RailsLogger
def start_mirror(project) def start_mirror(project)
import_state = project.import_state import_state = project.import_state
...@@ -48,18 +49,19 @@ class RepositoryUpdateMirrorWorker ...@@ -48,18 +49,19 @@ class RepositoryUpdateMirrorWorker
false false
end end
end end
# rubocop:enable Gitlab/RailsLogger
def fail_mirror(project, message) def fail_mirror(project, message)
project.import_state.mark_as_failed(message) project.import_state.mark_as_failed(message)
Rails.logger.error("Mirror update for #{project.full_path} failed with the following message: #{message}") Rails.logger.error("Mirror update for #{project.full_path} failed with the following message: #{message}") # rubocop:disable Gitlab/RailsLogger
end end
def finish_mirror(project) def finish_mirror(project)
import_state = project.import_state import_state = project.import_state
import_state.finish import_state.finish
Rails.logger.info("Mirror update for #{project.full_path} successfully finished. Update duration: #{import_state.mirror_update_duration}}.") Rails.logger.info("Mirror update for #{project.full_path} successfully finished. Update duration: #{import_state.mirror_update_duration}}.") # rubocop:disable Gitlab/RailsLogger
metric_mirror_update_duration_seconds.observe({}, import_state.mirror_update_duration) metric_mirror_update_duration_seconds.observe({}, import_state.mirror_update_duration)
end end
......
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def initialize(entry, adapter = nil) def initialize(entry, adapter = nil)
Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } # rubocop:disable Gitlab/RailsLogger
@entry = entry @entry = entry
@adapter = adapter @adapter = adapter
end end
...@@ -159,14 +159,14 @@ module EE ...@@ -159,14 +159,14 @@ module EE
begin begin
base = ::Gitlab::Auth::LDAP::DN.new(adapter.config.base).to_a base = ::Gitlab::Auth::LDAP::DN.new(adapter.config.base).to_a
rescue ::Gitlab::Auth::LDAP::DN::FormatError => e rescue ::Gitlab::Auth::LDAP::DN::FormatError => e
Rails.logger.error "Configured LDAP `base` is invalid: '#{adapter.config.base}'. Error: \"#{e.message}\"" Rails.logger.error "Configured LDAP `base` is invalid: '#{adapter.config.base}'. Error: \"#{e.message}\"" # rubocop:disable Gitlab/RailsLogger
return [] return []
end end
members.select do |dn| members.select do |dn|
::Gitlab::Auth::LDAP::DN.new(dn).to_a.last(base.length) == base ::Gitlab::Auth::LDAP::DN.new(dn).to_a.last(base.length) == base
rescue ::Gitlab::Auth::LDAP::DN::FormatError => e rescue ::Gitlab::Auth::LDAP::DN::FormatError => e
Rails.logger.warn "Received invalid member DN from LDAP group '#{cn}': '#{dn}'. Error: \"#{e.message}\". Skipping" Rails.logger.warn "Received invalid member DN from LDAP group '#{cn}': '#{dn}'. Error: \"#{e.message}\". Skipping" # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -183,7 +183,7 @@ module EE ...@@ -183,7 +183,7 @@ module EE
if dns if dns
normalize_dns(dns) normalize_dns(dns)
else else
Rails.logger.warn("Could not find member DNs for LDAP group #{entry.inspect}") Rails.logger.warn("Could not find member DNs for LDAP group #{entry.inspect}") # rubocop:disable Gitlab/RailsLogger
[] []
end end
end end
......
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
begin begin
group.start_ldap_sync group.start_ldap_sync
Rails.logger.debug { "Started syncing all providers for '#{group.name}' group" } Rails.logger.debug { "Started syncing all providers for '#{group.name}' group" } # rubocop:disable Gitlab/RailsLogger
# Shuffle providers to prevent a scenario where sync fails after a time # Shuffle providers to prevent a scenario where sync fails after a time
# and only the first provider or two get synced. This shuffles the order # and only the first provider or two get synced. This shuffles the order
...@@ -28,9 +28,9 @@ module EE ...@@ -28,9 +28,9 @@ module EE
end end
group.finish_ldap_sync group.finish_ldap_sync
Rails.logger.debug { "Finished syncing all providers for '#{group.name}' group" } Rails.logger.debug { "Finished syncing all providers for '#{group.name}' group" } # rubocop:disable Gitlab/RailsLogger
rescue ::Gitlab::Auth::LDAP::LDAPConnectionError rescue ::Gitlab::Auth::LDAP::LDAPConnectionError
Rails.logger.warn("Error syncing all providers for '#{group.name}' group") Rails.logger.warn("Error syncing all providers for '#{group.name}' group") # rubocop:disable Gitlab/RailsLogger
group.fail_ldap_sync group.fail_ldap_sync
end end
end end
...@@ -41,15 +41,15 @@ module EE ...@@ -41,15 +41,15 @@ module EE
begin begin
group.start_ldap_sync group.start_ldap_sync
Rails.logger.debug { "Started syncing '#{proxy.provider}' provider for '#{group.name}' group" } Rails.logger.debug { "Started syncing '#{proxy.provider}' provider for '#{group.name}' group" } # rubocop:disable Gitlab/RailsLogger
sync_group = new(group, proxy) sync_group = new(group, proxy)
sync_group.update_permissions sync_group.update_permissions
group.finish_ldap_sync group.finish_ldap_sync
Rails.logger.debug { "Finished syncing '#{proxy.provider}' provider for '#{group.name}' group" } Rails.logger.debug { "Finished syncing '#{proxy.provider}' provider for '#{group.name}' group" } # rubocop:disable Gitlab/RailsLogger
rescue ::Gitlab::Auth::LDAP::LDAPConnectionError rescue ::Gitlab::Auth::LDAP::LDAPConnectionError
Rails.logger.warn("Error syncing '#{proxy.provider}' provider for '#{group.name}' group") Rails.logger.warn("Error syncing '#{proxy.provider}' provider for '#{group.name}' group") # rubocop:disable Gitlab/RailsLogger
group.fail_ldap_sync group.fail_ldap_sync
end end
end end
...@@ -59,7 +59,7 @@ module EE ...@@ -59,7 +59,7 @@ module EE
return true unless group.ldap_sync_started? return true unless group.ldap_sync_started?
Rails.logger.warn "Group '#{group.name}' is not ready for LDAP sync. Skipping" Rails.logger.warn "Group '#{group.name}' is not ready for LDAP sync. Skipping" # rubocop:disable Gitlab/RailsLogger
false false
end end
...@@ -253,7 +253,7 @@ module EE ...@@ -253,7 +253,7 @@ module EE
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def logger def logger
Rails.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
def config def config
......
...@@ -92,7 +92,7 @@ module EE ...@@ -92,7 +92,7 @@ module EE
end end
def logger def logger
Rails.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -144,7 +144,7 @@ module EE ...@@ -144,7 +144,7 @@ module EE
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def logger def logger
Rails.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -39,7 +39,7 @@ module EE ...@@ -39,7 +39,7 @@ module EE
true true
rescue ::Gitlab::Auth::LDAP::LDAPConnectionError rescue ::Gitlab::Auth::LDAP::LDAPConnectionError
Rails.logger.warn("Error syncing #{attribute} users for provider '#{provider}'. LDAP connection Error") Rails.logger.warn("Error syncing #{attribute} users for provider '#{provider}'. LDAP connection Error") # rubocop:disable Gitlab/RailsLogger
false false
end end
...@@ -64,7 +64,7 @@ module EE ...@@ -64,7 +64,7 @@ module EE
user user
else else
Rails.logger.debug do Rails.logger.debug do # rubocop:disable Gitlab/RailsLogger
<<-MSG.strip_heredoc.tr("\n", ' ') <<-MSG.strip_heredoc.tr("\n", ' ')
#{self.class.name}: User with DN `#{member_dn}` should be marked as #{self.class.name}: User with DN `#{member_dn}` should be marked as
#{attribute} but there is no user in GitLab with that identity. #{attribute} but there is no user in GitLab with that identity.
......
...@@ -37,7 +37,7 @@ module EE ...@@ -37,7 +37,7 @@ module EE
end end
def logger def logger
Rails.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -8,7 +8,7 @@ module EE ...@@ -8,7 +8,7 @@ module EE
override :move_attributes_data_to_import_state override :move_attributes_data_to_import_state
def move_attributes_data_to_import_state(start_id, end_id) def move_attributes_data_to_import_state(start_id, end_id)
Rails.logger.info("#{self.class.name} - Moving import attributes data to project mirror data table: #{start_id} - #{end_id}") Rails.logger.info("#{self.class.name} - Moving import attributes data to project mirror data table: #{start_id} - #{end_id}") # rubocop:disable Gitlab/RailsLogger
ActiveRecord::Base.connection.execute <<~SQL ActiveRecord::Base.connection.execute <<~SQL
INSERT INTO project_mirror_data (project_id, status, jid, last_update_at, last_successful_update_at, last_error) INSERT INTO project_mirror_data (project_id, status, jid, last_update_at, last_successful_update_at, last_error)
......
...@@ -8,7 +8,7 @@ module EE ...@@ -8,7 +8,7 @@ module EE
override :move_attributes_data_to_project override :move_attributes_data_to_project
def move_attributes_data_to_project(start_id, end_id) def move_attributes_data_to_project(start_id, end_id)
Rails.logger.info("#{self.class.name} - Moving import attributes data to projects table: #{start_id} - #{end_id}") Rails.logger.info("#{self.class.name} - Moving import attributes data to projects table: #{start_id} - #{end_id}") # rubocop:disable Gitlab/RailsLogger
if ::Gitlab::Database.mysql? if ::Gitlab::Database.mysql?
ActiveRecord::Base.connection.execute <<~SQL ActiveRecord::Base.connection.execute <<~SQL
......
...@@ -30,7 +30,7 @@ module Gitlab ...@@ -30,7 +30,7 @@ module Gitlab
# Not added to Gitlab::Shell because I don't expect this to be used again # Not added to Gitlab::Shell because I don't expect this to be used again
def batch_add_keys_in_db_starting_from(start_id) def batch_add_keys_in_db_starting_from(start_id)
Rails.logger.info("Adding all keys starting from ID: #{start_id}") Rails.logger.info("Adding all keys starting from ID: #{start_id}") # rubocop:disable Gitlab/RailsLogger
::Key.find_in_batches(start: start_id, batch_size: 1000) do |keys| ::Key.find_in_batches(start: start_id, batch_size: 1000) do |keys|
gitlab_shell.batch_add_keys(keys) gitlab_shell.batch_add_keys(keys)
......
...@@ -69,11 +69,13 @@ module Gitlab ...@@ -69,11 +69,13 @@ module Gitlab
} }
end end
# rubocop:disable Gitlab/RailsLogger
def self.log(level, message) def self.log(level, message)
Rails.logger.tagged(LOG_TAG) do Rails.logger.tagged(LOG_TAG) do
Rails.logger.send(level, message) Rails.logger.send(level, message)
end end
end end
# rubocop:enable Gitlab/RailsLogger
def self.pool_size def self.pool_size
ActiveRecord::Base.configurations[Rails.env]['pool'] ActiveRecord::Base.configurations[Rails.env]['pool']
......
...@@ -43,7 +43,7 @@ module Gitlab ...@@ -43,7 +43,7 @@ module Gitlab
# Sentry, instead of silently terminating this thread. # Sentry, instead of silently terminating this thread.
Raven.capture_exception(error) Raven.capture_exception(error)
Rails.logger.error( Rails.logger.error( # rubocop:disable Gitlab/RailsLogger
"Service discovery encountered an error: #{error.message}" "Service discovery encountered an error: #{error.message}"
) )
......
...@@ -132,7 +132,7 @@ module Gitlab ...@@ -132,7 +132,7 @@ module Gitlab
end end
def log_level def log_level
options[:debug] ? :debug : Rails.logger.level options[:debug] ? :debug : Rails.logger.level # rubocop:disable Gitlab/RailsLogger
end end
def event_data(event_log) def event_data(event_log)
......
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
end end
def self.build def self.build
super.tap { |logger| logger.level = Rails.logger.level } super.tap { |logger| logger.level = Rails.logger.level } # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
available = max_capacity - current_capacity available = max_capacity - current_capacity
if available < 0 if available < 0
Rails.logger.info("Mirror available capacity is below 0: #{available}") Rails.logger.info("Mirror available capacity is below 0: #{available}") # rubocop:disable Gitlab/RailsLogger
available = 0 available = 0
end end
......
...@@ -59,7 +59,7 @@ module Pseudonymizer ...@@ -59,7 +59,7 @@ module Pseudonymizer
pseudonymity_columns) pseudonymity_columns)
) )
rescue => e rescue => e
Rails.logger.error("Failed to export #{table}: #{e}") Rails.logger.error("Failed to export #{table}: #{e}") # rubocop:disable Gitlab/RailsLogger
raise e raise e
end end
...@@ -115,7 +115,7 @@ module Pseudonymizer ...@@ -115,7 +115,7 @@ module Pseudonymizer
file_path = output_filename(table) file_path = output_filename(table)
headers = contents.peek.keys headers = contents.peek.keys
Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}." Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}." # rubocop:disable Gitlab/RailsLogger
Zlib::GzipWriter.open(file_path) do |io| Zlib::GzipWriter.open(file_path) do |io|
csv = CSV.new(io, headers: headers, write_headers: true) csv = CSV.new(io, headers: headers, write_headers: true)
contents.each { |row| csv << row.values } contents.each { |row| csv << row.values }
...@@ -123,7 +123,7 @@ module Pseudonymizer ...@@ -123,7 +123,7 @@ module Pseudonymizer
file_path file_path
rescue StopIteration rescue StopIteration
Rails.logger.info "#{self.class.name} table #{table} is empty." Rails.logger.info "#{self.class.name} table #{table} is empty." # rubocop:disable Gitlab/RailsLogger
nil nil
end end
end end
......
...@@ -33,7 +33,7 @@ module Pseudonymizer ...@@ -33,7 +33,7 @@ module Pseudonymizer
pseudo_extra_fields = pseudonymized - whitelisted pseudo_extra_fields = pseudonymized - whitelisted
pseudo_extra_fields.each do |field| pseudo_extra_fields.each do |field|
Rails.logger.warn("#{self.class.name} extraneous pseudo: #{@table}.#{field} is not whitelisted and will be ignored.") Rails.logger.warn("#{self.class.name} extraneous pseudo: #{@table}.#{field} is not whitelisted and will be ignored.") # rubocop:disable Gitlab/RailsLogger
end end
pseudonymized & whitelisted pseudonymized & whitelisted
......
...@@ -31,7 +31,7 @@ module Pseudonymizer ...@@ -31,7 +31,7 @@ module Pseudonymizer
ORDER BY id ORDER BY id
LIMIT #{PAGE_SIZE} LIMIT #{PAGE_SIZE}
SQL SQL
Rails.logger.debug("#{self.class.name} fetch ids [#{id_offset}..+#{PAGE_SIZE}]") Rails.logger.debug("#{self.class.name} fetch ids [#{id_offset}..+#{PAGE_SIZE}]") # rubocop:disable Gitlab/RailsLogger
break if results.empty? break if results.empty?
id_offset = results.last["id"].to_i id_offset = results.last["id"].to_i
...@@ -52,7 +52,7 @@ module Pseudonymizer ...@@ -52,7 +52,7 @@ module Pseudonymizer
ORDER BY #{@columns.join(",")} ORDER BY #{@columns.join(",")}
LIMIT #{PAGE_SIZE} OFFSET #{offset} LIMIT #{PAGE_SIZE} OFFSET #{offset}
SQL SQL
Rails.logger.debug("#{self.class.name} fetching offset [#{offset}..#{offset + PAGE_SIZE}]") Rails.logger.debug("#{self.class.name} fetching offset [#{offset}..#{offset + PAGE_SIZE}]") # rubocop:disable Gitlab/RailsLogger
break if results.empty? break if results.empty?
offset += PAGE_SIZE offset += PAGE_SIZE
......
...@@ -72,7 +72,7 @@ module API ...@@ -72,7 +72,7 @@ module API
result == 'PONG' result == 'PONG'
rescue => e rescue => e
Rails.logger.warn("GitLab: An unexpected error occurred in pinging to Redis: #{e}") Rails.logger.warn("GitLab: An unexpected error occurred in pinging to Redis: #{e}") # rubocop:disable Gitlab/RailsLogger
false false
end end
......
...@@ -96,6 +96,7 @@ module Gitlab ...@@ -96,6 +96,7 @@ module Gitlab
end end
end end
# rubocop:disable Gitlab/RailsLogger
def rate_limit!(ip, success:, login:) def rate_limit!(ip, success:, login:)
rate_limiter = Gitlab::Auth::IpRateLimiter.new(ip) rate_limiter = Gitlab::Auth::IpRateLimiter.new(ip)
return unless rate_limiter.enabled? return unless rate_limiter.enabled?
...@@ -116,6 +117,7 @@ module Gitlab ...@@ -116,6 +117,7 @@ module Gitlab
end end
end end
end end
# rubocop:enable Gitlab/RailsLogger
private private
......
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
response = ldap.get_operation_result response = ldap.get_operation_result
unless response.code.zero? unless response.code.zero?
Rails.logger.warn("LDAP search error: #{response.message}") Rails.logger.warn("LDAP search error: #{response.message}") # rubocop:disable Gitlab/RailsLogger
end end
[] []
...@@ -69,7 +69,7 @@ module Gitlab ...@@ -69,7 +69,7 @@ module Gitlab
retries += 1 retries += 1
error_message = connection_error_message(error) error_message = connection_error_message(error)
Rails.logger.warn(error_message) Rails.logger.warn(error_message) # rubocop:disable Gitlab/RailsLogger
if retries < MAX_SEARCH_RETRIES if retries < MAX_SEARCH_RETRIES
renew_connection_adapter renew_connection_adapter
......
...@@ -242,7 +242,7 @@ module Gitlab ...@@ -242,7 +242,7 @@ module Gitlab
begin begin
custom_options[:cert] = OpenSSL::X509::Certificate.new(custom_options[:cert]) custom_options[:cert] = OpenSSL::X509::Certificate.new(custom_options[:cert])
rescue OpenSSL::X509::CertificateError => e rescue OpenSSL::X509::CertificateError => e
Rails.logger.error "LDAP TLS Options 'cert' is invalid for provider #{provider}: #{e.message}" Rails.logger.error "LDAP TLS Options 'cert' is invalid for provider #{provider}: #{e.message}" # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -250,7 +250,7 @@ module Gitlab ...@@ -250,7 +250,7 @@ module Gitlab
begin begin
custom_options[:key] = OpenSSL::PKey.read(custom_options[:key]) custom_options[:key] = OpenSSL::PKey.read(custom_options[:key])
rescue OpenSSL::PKey::PKeyError => e rescue OpenSSL::PKey::PKeyError => e
Rails.logger.error "LDAP TLS Options 'key' is invalid for provider #{provider}: #{e.message}" Rails.logger.error "LDAP TLS Options 'key' is invalid for provider #{provider}: #{e.message}" # rubocop:disable Gitlab/RailsLogger
end end
end end
......
...@@ -47,7 +47,7 @@ module Gitlab ...@@ -47,7 +47,7 @@ module Gitlab
def self.normalize_dn(dn) def self.normalize_dn(dn)
::Gitlab::Auth::LDAP::DN.new(dn).to_normalized_s ::Gitlab::Auth::LDAP::DN.new(dn).to_normalized_s
rescue ::Gitlab::Auth::LDAP::DN::FormatError => e rescue ::Gitlab::Auth::LDAP::DN::FormatError => e
Rails.logger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}") Rails.logger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}") # rubocop:disable Gitlab/RailsLogger
dn dn
end end
...@@ -59,13 +59,13 @@ module Gitlab ...@@ -59,13 +59,13 @@ module Gitlab
def self.normalize_uid(uid) def self.normalize_uid(uid)
::Gitlab::Auth::LDAP::DN.normalize_value(uid) ::Gitlab::Auth::LDAP::DN.normalize_value(uid)
rescue ::Gitlab::Auth::LDAP::DN::FormatError => e rescue ::Gitlab::Auth::LDAP::DN::FormatError => e
Rails.logger.info("Returning original UID \"#{uid}\" due to error during normalization attempt: #{e.message}") Rails.logger.info("Returning original UID \"#{uid}\" due to error during normalization attempt: #{e.message}") # rubocop:disable Gitlab/RailsLogger
uid uid
end end
def initialize(entry, provider) def initialize(entry, provider)
Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } # rubocop:disable Gitlab/RailsLogger
@entry = entry @entry = entry
@provider = provider @provider = provider
end end
......
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
end end
def perform(start_id, stop_id) def perform(start_id, stop_id)
Rails.logger.info("Setting commits_count for merge request diffs: #{start_id} - #{stop_id}") Rails.logger.info("Setting commits_count for merge request diffs: #{start_id} - #{stop_id}") # rubocop:disable Gitlab/RailsLogger
update = ' update = '
commits_count = ( commits_count = (
......
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
build.trace.archive! build.trace.archive!
rescue => e rescue => e
Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}" Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}" # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
.includes(project: [:route, :group, namespace: [:owner]]).find_each do |statistics| .includes(project: [:route, :group, namespace: [:owner]]).find_each do |statistics|
statistics.refresh!(only: [:wiki_size]) statistics.refresh!(only: [:wiki_size])
rescue => e rescue => e
Rails.logger.error "Failed to update wiki statistics. id: #{statistics.id} message: #{e.message}" Rails.logger.error "Failed to update wiki statistics. id: #{statistics.id} message: #{e.message}" # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -32,7 +32,7 @@ module Gitlab ...@@ -32,7 +32,7 @@ module Gitlab
) )
end end
rescue => e rescue => e
Rails.logger.error "Failed to update pages domain certificate valid time. id: #{domain.id}, message: #{e.message}" Rails.logger.error "Failed to update pages domain certificate valid time. id: #{domain.id}, message: #{e.message}" # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -108,7 +108,7 @@ module Gitlab ...@@ -108,7 +108,7 @@ module Gitlab
next unless matching_label next unless matching_label
Rails.logger.info "#{resource.class.name.demodulize} #{resource.id}: replacing #{label.label_id} with #{matching_label.id}" Rails.logger.info "#{resource.class.name.demodulize} #{resource.id}: replacing #{label.label_id} with #{matching_label.id}" # rubocop:disable Gitlab/RailsLogger
LabelLink.update(label.label_link_id, label_id: matching_label.id) LabelLink.update(label.label_link_id, label_id: matching_label.id)
end end
end end
......
...@@ -42,7 +42,7 @@ module Gitlab ...@@ -42,7 +42,7 @@ module Gitlab
#{e.message} #{e.message}
#{e.backtrace.join("\n ")} #{e.backtrace.join("\n ")}
MSG MSG
Rails.logger.error(msg) Rails.logger.error(msg) # rubocop:disable Gitlab/RailsLogger
false false
end end
end end
......
...@@ -111,7 +111,7 @@ module Gitlab ...@@ -111,7 +111,7 @@ module Gitlab
cmd = %W[#{ionice} -c Idle] + cmd if ionice cmd = %W[#{ionice} -c Idle] + cmd if ionice
log_msg = "PrepareUntrackedUploads find command: \"#{cmd.join(' ')}\"" log_msg = "PrepareUntrackedUploads find command: \"#{cmd.join(' ')}\""
Rails.logger.info log_msg Rails.logger.info log_msg # rubocop:disable Gitlab/RailsLogger
cmd cmd
end end
......
...@@ -17,7 +17,7 @@ module Gitlab ...@@ -17,7 +17,7 @@ module Gitlab
@limit = limit @limit = limit
@dry_run = dry_run @dry_run = dry_run
@niceness = niceness || DEFAULT_NICENESS @niceness = niceness || DEFAULT_NICENESS
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
@total_found = @total_cleaned = 0 @total_found = @total_cleaned = 0
new_batch! new_batch!
......
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
attr_reader :batch_size, :dry_run attr_reader :batch_size, :dry_run
attr_accessor :artifact_files attr_accessor :artifact_files
def initialize(batch_size:, dry_run: true, logger: Rails.logger) def initialize(batch_size:, dry_run: true, logger: Rails.logger) # rubocop:disable Gitlab/RailsLogger
@batch_size = batch_size @batch_size = batch_size
@dry_run = dry_run @dry_run = dry_run
@logger = logger @logger = logger
......
...@@ -49,7 +49,7 @@ module Gitlab ...@@ -49,7 +49,7 @@ module Gitlab
cmd = %W[#{ionice} -c Idle] + cmd if ionice cmd = %W[#{ionice} -c Idle] + cmd if ionice
log_msg = "find command: \"#{cmd.join(' ')}\"" log_msg = "find command: \"#{cmd.join(' ')}\""
Rails.logger.info log_msg Rails.logger.info log_msg # rubocop:disable Gitlab/RailsLogger
cmd cmd
end end
......
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
attr_reader :logger attr_reader :logger
def initialize(logger: nil) def initialize(logger: nil)
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
def run!(dry_run: true) def run!(dry_run: true)
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
BATCH_SIZE = 100 BATCH_SIZE = 100
def initialize(logger: nil) def initialize(logger: nil)
@logger = logger || Rails.logger @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger
end end
def run!(dry_run: false) def run!(dry_run: false)
......
...@@ -310,7 +310,7 @@ module Gitlab ...@@ -310,7 +310,7 @@ module Gitlab
gitlab_database_transaction_seconds.observe(labels, duration_seconds) gitlab_database_transaction_seconds.observe(labels, duration_seconds)
rescue Prometheus::Client::LabelSetValidator::LabelSetError => err rescue Prometheus::Client::LabelSetValidator::LabelSetError => err
# Ensure that errors in recording these metrics don't affect the operation of the application # Ensure that errors in recording these metrics don't affect the operation of the application
Rails.logger.error("Unable to observe database transaction duration: #{err}") Rails.logger.error("Unable to observe database transaction duration: #{err}") # rubocop:disable Gitlab/RailsLogger
end end
# MonkeyPatch for ActiveRecord::Base for adding observability # MonkeyPatch for ActiveRecord::Base for adding observability
......
...@@ -61,7 +61,7 @@ module Gitlab ...@@ -61,7 +61,7 @@ module Gitlab
end end
if index_exists?(table_name, column_name, options) if index_exists?(table_name, column_name, options)
Rails.logger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" Rails.logger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger
return return
end end
...@@ -91,7 +91,7 @@ module Gitlab ...@@ -91,7 +91,7 @@ module Gitlab
end end
unless index_exists?(table_name, column_name, options) unless index_exists?(table_name, column_name, options)
Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger
return return
end end
...@@ -121,7 +121,7 @@ module Gitlab ...@@ -121,7 +121,7 @@ module Gitlab
end end
unless index_exists_by_name?(table_name, index_name) unless index_exists_by_name?(table_name, index_name)
Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}" Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}" # rubocop:disable Gitlab/RailsLogger
return return
end end
...@@ -149,6 +149,8 @@ module Gitlab ...@@ -149,6 +149,8 @@ module Gitlab
# column - The name of the column to create the foreign key on. # column - The name of the column to create the foreign key on.
# on_delete - The action to perform when associated data is removed, # on_delete - The action to perform when associated data is removed,
# defaults to "CASCADE". # defaults to "CASCADE".
#
# rubocop:disable Gitlab/RailsLogger
def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil) def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil)
# Transactions would result in ALTER TABLE locks being held for the # Transactions would result in ALTER TABLE locks being held for the
# duration of the transaction, defeating the purpose of this method. # duration of the transaction, defeating the purpose of this method.
...@@ -208,6 +210,7 @@ module Gitlab ...@@ -208,6 +210,7 @@ module Gitlab
execute("ALTER TABLE #{source} VALIDATE CONSTRAINT #{key_name};") execute("ALTER TABLE #{source} VALIDATE CONSTRAINT #{key_name};")
end end
end end
# rubocop:enable Gitlab/RailsLogger
def foreign_key_exists?(source, target = nil, column: nil) def foreign_key_exists?(source, target = nil, column: nil)
foreign_keys(source).any? do |key| foreign_keys(source).any? do |key|
......
...@@ -70,7 +70,7 @@ module Gitlab ...@@ -70,7 +70,7 @@ module Gitlab
unless gitlab_shell.mv_namespace(repository_storage, old_full_path, new_full_path) unless gitlab_shell.mv_namespace(repository_storage, old_full_path, new_full_path)
message = "Exception moving on shard #{repository_storage} from #{old_full_path} to #{new_full_path}" message = "Exception moving on shard #{repository_storage} from #{old_full_path} to #{new_full_path}"
Rails.logger.error message Rails.logger.error message # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
unless gitlab_shell.mv_repository(project.repository_storage, unless gitlab_shell.mv_repository(project.repository_storage,
old_path, old_path,
new_path) new_path)
Rails.logger.error "Error moving #{old_path} to #{new_path}" Rails.logger.error "Error moving #{old_path} to #{new_path}" # rubocop:disable Gitlab/RailsLogger
end end
end end
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
def self.delivering_email(message) def self.delivering_email(message)
message.perform_deliveries = false message.perform_deliveries = false
Rails.logger.info "Emails disabled! Interceptor prevented sending mail #{message.subject}" Rails.logger.info "Emails disabled! Interceptor prevented sending mail #{message.subject}" # rubocop:disable Gitlab/RailsLogger
end end
end end
end end
......
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,7 @@ module Gitlab
begin begin
CharlockHolmes::Converter.convert(message, detect[:encoding], 'UTF-8') CharlockHolmes::Converter.convert(message, detect[:encoding], 'UTF-8')
rescue ArgumentError => e rescue ArgumentError => e
Rails.logger.warn("Ignoring error converting #{detect[:encoding]} into UTF8: #{e.message}") Rails.logger.warn("Ignoring error converting #{detect[:encoding]} into UTF8: #{e.message}") # rubocop:disable Gitlab/RailsLogger
'' ''
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment