Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a05820b8
Commit
a05820b8
authored
Sep 06, 2020
by
Rajendra Kadam
Committed by
Peter Leitzen
Sep 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use applogger in update_mirror_worker, access.rb and group.rb
parent
3aefe1d1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
21 deletions
+23
-21
changelogs/unreleased/app-logger-4.yml
changelogs/unreleased/app-logger-4.yml
+5
-0
ee/app/workers/repository_update_mirror_worker.rb
ee/app/workers/repository_update_mirror_worker.rb
+4
-7
ee/lib/ee/gitlab/auth/ldap/access.rb
ee/lib/ee/gitlab/auth/ldap/access.rb
+6
-6
ee/lib/ee/gitlab/auth/ldap/group.rb
ee/lib/ee/gitlab/auth/ldap/group.rb
+4
-4
ee/spec/lib/ee/gitlab/auth/ldap/group_spec.rb
ee/spec/lib/ee/gitlab/auth/ldap/group_spec.rb
+3
-3
lib/gitlab/auth/ldap/person.rb
lib/gitlab/auth/ldap/person.rb
+1
-1
No files found.
changelogs/unreleased/app-logger-4.yml
0 → 100644
View file @
a05820b8
---
title
:
Use applogger in group.rb, access.rb and repo update mirror worker
merge_request
:
41049
author
:
Rajendra Kadam
type
:
other
ee/app/workers/repository_update_mirror_worker.rb
View file @
a05820b8
...
...
@@ -37,33 +37,30 @@ class RepositoryUpdateMirrorWorker # rubocop:disable Scalability/IdempotentWorke
private
# rubocop:disable Gitlab/RailsLogger
def
start_mirror
(
project
)
import_state
=
project
.
import_state
if
start
(
import_state
)
Rails
.
l
ogger
.
info
(
"Mirror update for
#{
project
.
full_path
}
started. Waiting duration:
#{
import_state
.
mirror_waiting_duration
}
"
)
Gitlab
::
AppL
ogger
.
info
(
"Mirror update for
#{
project
.
full_path
}
started. Waiting duration:
#{
import_state
.
mirror_waiting_duration
}
"
)
metric_mirror_waiting_duration_seconds
.
observe
({},
import_state
.
mirror_waiting_duration
)
true
else
Rails
.
l
ogger
.
info
(
"Project
#{
project
.
full_path
}
was in inconsistent state:
#{
import_state
.
status
}
"
)
Gitlab
::
AppL
ogger
.
info
(
"Project
#{
project
.
full_path
}
was in inconsistent state:
#{
import_state
.
status
}
"
)
false
end
end
# rubocop:enable Gitlab/RailsLogger
def
fail_mirror
(
project
,
message
)
project
.
import_state
.
mark_as_failed
(
message
)
Rails
.
logger
.
error
(
"Mirror update for
#{
project
.
full_path
}
failed with the following message:
#{
message
}
"
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppLogger
.
error
(
"Mirror update for
#{
project
.
full_path
}
failed with the following message:
#{
message
}
"
)
end
def
finish_mirror
(
project
)
import_state
=
project
.
import_state
import_state
.
finish
Rails
.
logger
.
info
(
"Mirror update for
#{
project
.
full_path
}
successfully finished. Update duration:
#{
import_state
.
mirror_update_duration
}
}."
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppLogger
.
info
(
"Mirror update for
#{
project
.
full_path
}
successfully finished. Update duration:
#{
import_state
.
mirror_update_duration
}
}."
)
metric_mirror_update_duration_seconds
.
observe
({},
import_state
.
mirror_update_duration
)
end
...
...
ee/lib/ee/gitlab/auth/ldap/access.rb
View file @
a05820b8
...
...
@@ -43,12 +43,12 @@ module EE
keys
=
ldap_user
.
ssh_keys
-
user
.
keys
.
ldap
.
pluck
(
:key
)
keys
.
each
do
|
key
|
::
Rails
.
l
ogger
.
info
"
#{
self
.
class
.
name
}
: adding LDAP SSH key
#{
key
.
inspect
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)"
::
Gitlab
::
AppL
ogger
.
info
"
#{
self
.
class
.
name
}
: adding LDAP SSH key
#{
key
.
inspect
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)"
new_key
=
::
LDAPKey
.
new
(
title:
"LDAP -
#{
ldap_config
.
sync_ssh_keys
}
"
,
key:
key
)
new_key
.
user
=
user
unless
new_key
.
save
::
Rails
.
l
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to add LDAP SSH key
#{
key
.
inspect
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
::
Gitlab
::
AppL
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to add LDAP SSH key
#{
key
.
inspect
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
"error messages:
#{
new_key
.
errors
.
messages
}
"
end
end
...
...
@@ -61,10 +61,10 @@ module EE
keys
=
user
.
keys
.
ldap
.
where
.
not
(
key:
ldap_user
.
ssh_keys
)
keys
.
each
do
|
deleted_key
|
::
Rails
.
l
ogger
.
info
"
#{
self
.
class
.
name
}
: removing LDAP SSH key
#{
deleted_key
.
key
}
from
#{
user
.
name
}
(
#{
user
.
id
}
)"
::
Gitlab
::
AppL
ogger
.
info
"
#{
self
.
class
.
name
}
: removing LDAP SSH key
#{
deleted_key
.
key
}
from
#{
user
.
name
}
(
#{
user
.
id
}
)"
unless
deleted_key
.
destroy
::
Rails
.
l
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to remove LDAP SSH key
#{
key
.
inspect
}
from
#{
user
.
name
}
(
#{
user
.
id
}
)"
::
Gitlab
::
AppL
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to remove LDAP SSH key
#{
key
.
inspect
}
from
#{
user
.
name
}
(
#{
user
.
id
}
)"
end
end
end
...
...
@@ -83,7 +83,7 @@ module EE
kerberos_identity
||=
::
Identity
.
new
(
provider: :kerberos
,
user:
user
)
kerberos_identity
.
extern_uid
=
ldap_user
.
kerberos_principal
unless
kerberos_identity
.
save
::
Rails
.
l
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to add Kerberos principal
#{
ldap_user
.
kerberos_principal
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
::
Gitlab
::
AppL
ogger
.
error
"
#{
self
.
class
.
name
}
: failed to add Kerberos principal
#{
ldap_user
.
kerberos_principal
}
to
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
"error messages:
#{
kerberos_identity
.
errors
.
messages
}
"
end
end
...
...
@@ -109,7 +109,7 @@ module EE
return
if
ldap_user
.
dn
.
empty?
||
ldap_user
.
dn
==
ldap_identity
.
extern_uid
unless
ldap_identity
.
update
(
extern_uid:
ldap_user
.
dn
)
::
Rails
.
l
ogger
.
error
"Could not update DN for
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
::
Gitlab
::
AppL
ogger
.
error
"Could not update DN for
#{
user
.
name
}
(
#{
user
.
id
}
)
\n
"
\
"error messages:
#{
user
.
ldap_identity
.
errors
.
messages
}
"
end
end
...
...
ee/lib/ee/gitlab/auth/ldap/group.rb
View file @
a05820b8
...
...
@@ -16,7 +16,7 @@ module EE
# rubocop: enable CodeReuse/ActiveRecord
def
initialize
(
entry
,
adapter
=
nil
)
Rails
.
logger
.
debug
{
"Instantiating
#{
self
.
class
.
name
}
with LDIF:
\n
#{
entry
.
to_ldif
}
"
}
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
debug
"Instantiating
#{
self
.
class
.
name
}
with LDIF:
\n
#{
entry
.
to_ldif
}
"
@entry
=
entry
@adapter
=
adapter
end
...
...
@@ -159,14 +159,14 @@ module EE
begin
base
=
::
Gitlab
::
Auth
::
Ldap
::
DN
.
new
(
adapter
.
config
.
base
).
to_a
rescue
::
Gitlab
::
Auth
::
Ldap
::
DN
::
FormatError
=>
e
Rails
.
logger
.
error
"Configured LDAP `base` is invalid: '
#{
adapter
.
config
.
base
}
'. Error:
\"
#{
e
.
message
}
\"
"
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
error
"Configured LDAP `base` is invalid: '
#{
adapter
.
config
.
base
}
'. Error:
\"
#{
e
.
message
}
\"
"
return
[]
end
members
.
select
do
|
dn
|
::
Gitlab
::
Auth
::
Ldap
::
DN
.
new
(
dn
).
to_a
.
last
(
base
.
length
)
==
base
rescue
::
Gitlab
::
Auth
::
Ldap
::
DN
::
FormatError
=>
e
Rails
.
logger
.
warn
"Received invalid member DN from LDAP group '
#{
cn
}
': '
#{
dn
}
'. Error:
\"
#{
e
.
message
}
\"
. Skipping"
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
warn
"Received invalid member DN from LDAP group '
#{
cn
}
': '
#{
dn
}
'. Error:
\"
#{
e
.
message
}
\"
. Skipping"
end
end
...
...
@@ -183,7 +183,7 @@ module EE
if
dns
normalize_dns
(
dns
)
else
Rails
.
logger
.
warn
(
"Could not find member DNs for LDAP group
#{
entry
.
inspect
}
"
)
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
warn
(
"Could not find member DNs for LDAP group
#{
entry
.
inspect
}
"
)
[]
end
end
...
...
ee/spec/lib/ee/gitlab/auth/ldap/group_spec.rb
View file @
a05820b8
...
...
@@ -136,7 +136,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Group do
stub_ldap_adapter_nested_groups
(
group
.
dn
,
nested_groups
,
adapter
)
stub_ldap_adapter_nested_groups
(
group2_entry
.
dn
,
[],
adapter
)
expect
(
Rails
.
l
ogger
)
expect
(
Gitlab
::
AppL
ogger
)
.
to
receive
(
:error
).
with
(
/Configured LDAP `base` is invalid: 'invalid,dc=example,dc=com'/
)
# Users in the top-level group always get added - they're not filtered
# through the nested groups shenanigans.
...
...
@@ -161,9 +161,9 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Group do
stub_ldap_adapter_nested_groups
(
group2_entry
.
dn
,
[],
adapter
)
stub_ldap_adapter_nested_groups
(
group3_entry
.
dn
,
[],
adapter
)
expect
(
Rails
.
l
ogger
)
expect
(
Gitlab
::
AppL
ogger
)
.
to
receive
(
:info
).
with
(
/Returning original DN/
)
expect
(
Rails
.
l
ogger
)
expect
(
Gitlab
::
AppL
ogger
)
.
to
receive
(
:warn
).
with
(
/Received invalid member/
)
expect
(
group
.
member_dns
).
not_to
include
(
'invalid,ou=user,ou=groups,dc=example,dc=com'
)
end
...
...
lib/gitlab/auth/ldap/person.rb
View file @
a05820b8
...
...
@@ -45,7 +45,7 @@ module Gitlab
def
self
.
normalize_dn
(
dn
)
::
Gitlab
::
Auth
::
Ldap
::
DN
.
new
(
dn
).
to_normalized_s
rescue
::
Gitlab
::
Auth
::
Ldap
::
DN
::
FormatError
=>
e
Rails
.
l
ogger
.
info
(
"Returning original DN
\"
#{
dn
}
\"
due to error during normalization attempt:
#{
e
.
message
}
"
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppL
ogger
.
info
(
"Returning original DN
\"
#{
dn
}
\"
due to error during normalization attempt:
#{
e
.
message
}
"
)
# rubocop:disable Gitlab/RailsLogger
dn
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment