Commit 90ba61fa authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

This MR uses AppLogger in

group, proxy and other files.

This MR also adds a changelog
for the same

Add changelog

Fix spec failures and change changelog type

Fix spec failures

Fix spec failures
parent 1c20cf20
---
title: Use applogger in some files of lib/gitlab/ldap/sync/*
merge_request: 41051
author: Rajendra Kadam
type: other
......@@ -34,11 +34,11 @@ module EE
if config.admin_group.present?
sync_admin_users
else
logger.debug { "No `admin_group` configured for '#{provider}' provider. Skipping" }
logger.debug "No `admin_group` configured for '#{provider}' provider. Skipping"
end
if config.external_groups.empty?
logger.debug { "No `external_groups` configured for '#{provider}' provider. Skipping" }
logger.debug "No `external_groups` configured for '#{provider}' provider. Skipping"
else
sync_external_users
end
......@@ -49,32 +49,32 @@ module EE
private
def sync_groups
logger.debug { "Performing LDAP group sync for '#{provider}' provider" }
logger.debug "Performing LDAP group sync for '#{provider}' provider"
groups_where_group_links_with_provider_ordered.each do |group|
Sync::Group.execute(group, proxy)
end
logger.debug { "Finished LDAP group sync for '#{provider}' provider" }
logger.debug "Finished LDAP group sync for '#{provider}' provider"
end
def sync_admin_users
logger.debug { "Syncing admin users for '#{provider}' provider" }
logger.debug "Syncing admin users for '#{provider}' provider"
if Sync::AdminUsers.execute(proxy)
logger.debug { "Finished syncing admin users for '#{provider}' provider" }
logger.debug "Finished syncing admin users for '#{provider}' provider"
else
logger.debug { "Error syncing admin users for '#{provider}' provider. LDAP connection error" }
logger.debug "Error syncing admin users for '#{provider}' provider. LDAP connection error"
end
end
def sync_external_users
logger.debug { "Syncing external users for '#{provider}' provider" }
logger.debug "Syncing external users for '#{provider}' provider"
if Sync::ExternalUsers.execute(proxy)
logger.debug { "Finished syncing external users for '#{provider}' provider" }
logger.debug "Finished syncing external users for '#{provider}' provider"
else
logger.debug { "Error syncing external users for '#{provider}' provider. LDAP connection error" }
logger.debug "Error syncing external users for '#{provider}' provider. LDAP connection error"
end
end
......@@ -92,7 +92,7 @@ module EE
end
def logger
Rails.logger # rubocop:disable Gitlab/RailsLogger
::Gitlab::AppLogger
end
end
end
......
......@@ -45,7 +45,7 @@ module EE
def ldap_group_member_dns(ldap_group_cn)
ldap_group = Ldap::Group.find_by_cn(ldap_group_cn, adapter)
unless ldap_group.present?
logger.warn { "Cannot find LDAP group with CN '#{ldap_group_cn}'. Skipping" }
logger.warn "Cannot find LDAP group with CN '#{ldap_group_cn}'. Skipping"
return []
end
......@@ -64,7 +64,7 @@ module EE
ensure_full_dns!(member_dns)
logger.debug { "Members in '#{ldap_group.name}' LDAP group: #{member_dns}" }
logger.debug "Members in '#{ldap_group.name}' LDAP group: #{member_dns}"
# Various lookups in this method could return `nil` values.
# Compact the array to remove those entries
......@@ -80,7 +80,7 @@ module EE
dn_obj = ::Gitlab::Auth::Ldap::DN.new(dn)
parsed_dn = dn_obj.to_a
rescue ::Gitlab::Auth::Ldap::DN::FormatError => e
logger.error { "Found malformed DN: '#{dn}'. Skipping. Error: \"#{e.message}\"" }
logger.error "Found malformed DN: '#{dn}'. Skipping. Error: \"#{e.message}\""
next
end
......@@ -90,12 +90,12 @@ module EE
if parsed_dn.count > 2
dn_obj.to_normalized_s
elsif parsed_dn.count == 0
logger.warn { "Found null DN. Skipping." }
logger.warn "Found null DN. Skipping."
nil
elsif parsed_dn[0] == 'uid'
dn_for_uid(parsed_dn[1])
else
logger.warn { "Found potentially malformed/incomplete DN: '#{dn}'" }
logger.warn "Found potentially malformed/incomplete DN: '#{dn}'"
dn
end
......@@ -150,19 +150,19 @@ module EE
# rubocop: enable CodeReuse/ActiveRecord
def dn_filter_search(filter)
logger.debug { "Running filter \"#{filter}\" against #{provider}" }
logger.debug "Running filter \"#{filter}\" against #{provider}"
dns = adapter.filter_search(filter).map(&:dn)
ensure_full_dns!(dns)
logger.debug { "Found #{dns.count} matching users for filter #{filter}" }
logger.debug "Found #{dns.count} matching users for filter #{filter}"
dns
end
def logger
Rails.logger # rubocop:disable Gitlab/RailsLogger
::Gitlab::AppLogger
end
end
end
......
......@@ -41,7 +41,7 @@ module Gitlab
available = max_capacity - current_capacity
if available < 0
Rails.logger.info("Mirror available capacity is below 0: #{available}") # rubocop:disable Gitlab/RailsLogger
Gitlab::AppLogger.info("Mirror available capacity is below 0: #{available}")
available = 0
end
......
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