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
Hide 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
...
@@ -37,33 +37,30 @@ class RepositoryUpdateMirrorWorker # rubocop:disable Scalability/IdempotentWorke
private
private
# rubocop:disable Gitlab/RailsLogger
def
start_mirror
(
project
)
def
start_mirror
(
project
)
import_state
=
project
.
import_state
import_state
=
project
.
import_state
if
start
(
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
)
metric_mirror_waiting_duration_seconds
.
observe
({},
import_state
.
mirror_waiting_duration
)
true
true
else
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
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
)
Gitlab
::
AppLogger
.
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
}
}."
)
# 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
)
metric_mirror_update_duration_seconds
.
observe
({},
import_state
.
mirror_update_duration
)
end
end
...
...
ee/lib/ee/gitlab/auth/ldap/access.rb
View file @
a05820b8
...
@@ -43,12 +43,12 @@ module EE
...
@@ -43,12 +43,12 @@ module EE
keys
=
ldap_user
.
ssh_keys
-
user
.
keys
.
ldap
.
pluck
(
:key
)
keys
=
ldap_user
.
ssh_keys
-
user
.
keys
.
ldap
.
pluck
(
:key
)
keys
.
each
do
|
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
=
::
LDAPKey
.
new
(
title:
"LDAP -
#{
ldap_config
.
sync_ssh_keys
}
"
,
key:
key
)
new_key
.
user
=
user
new_key
.
user
=
user
unless
new_key
.
save
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
}
"
"error messages:
#{
new_key
.
errors
.
messages
}
"
end
end
end
end
...
@@ -61,10 +61,10 @@ module EE
...
@@ -61,10 +61,10 @@ module EE
keys
=
user
.
keys
.
ldap
.
where
.
not
(
key:
ldap_user
.
ssh_keys
)
keys
=
user
.
keys
.
ldap
.
where
.
not
(
key:
ldap_user
.
ssh_keys
)
keys
.
each
do
|
deleted_key
|
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
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
end
end
end
...
@@ -83,7 +83,7 @@ module EE
...
@@ -83,7 +83,7 @@ module EE
kerberos_identity
||=
::
Identity
.
new
(
provider: :kerberos
,
user:
user
)
kerberos_identity
||=
::
Identity
.
new
(
provider: :kerberos
,
user:
user
)
kerberos_identity
.
extern_uid
=
ldap_user
.
kerberos_principal
kerberos_identity
.
extern_uid
=
ldap_user
.
kerberos_principal
unless
kerberos_identity
.
save
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
}
"
"error messages:
#{
kerberos_identity
.
errors
.
messages
}
"
end
end
end
end
...
@@ -109,7 +109,7 @@ module EE
...
@@ -109,7 +109,7 @@ module EE
return
if
ldap_user
.
dn
.
empty?
||
ldap_user
.
dn
==
ldap_identity
.
extern_uid
return
if
ldap_user
.
dn
.
empty?
||
ldap_user
.
dn
==
ldap_identity
.
extern_uid
unless
ldap_identity
.
update
(
extern_uid:
ldap_user
.
dn
)
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
}
"
"error messages:
#{
user
.
ldap_identity
.
errors
.
messages
}
"
end
end
end
end
...
...
ee/lib/ee/gitlab/auth/ldap/group.rb
View file @
a05820b8
...
@@ -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
}
"
}
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
debug
"Instantiating
#{
self
.
class
.
name
}
with LDIF:
\n
#{
entry
.
to_ldif
}
"
@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
}
\"
"
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
error
"Configured LDAP `base` is invalid: '
#{
adapter
.
config
.
base
}
'. Error:
\"
#{
e
.
message
}
\"
"
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"
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
warn
"Received invalid member DN from LDAP group '
#{
cn
}
': '
#{
dn
}
'. Error:
\"
#{
e
.
message
}
\"
. Skipping"
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
}
"
)
# rubocop:disable Gitlab/RailsLogger
::
Gitlab
::
AppLogger
.
warn
(
"Could not find member DNs for LDAP group
#{
entry
.
inspect
}
"
)
[]
[]
end
end
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
...
@@ -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
(
group
.
dn
,
nested_groups
,
adapter
)
stub_ldap_adapter_nested_groups
(
group2_entry
.
dn
,
[],
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'/
)
.
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
# Users in the top-level group always get added - they're not filtered
# through the nested groups shenanigans.
# through the nested groups shenanigans.
...
@@ -161,9 +161,9 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Group do
...
@@ -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
(
group2_entry
.
dn
,
[],
adapter
)
stub_ldap_adapter_nested_groups
(
group3_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/
)
.
to
receive
(
:info
).
with
(
/Returning original DN/
)
expect
(
Rails
.
l
ogger
)
expect
(
Gitlab
::
AppL
ogger
)
.
to
receive
(
:warn
).
with
(
/Received invalid member/
)
.
to
receive
(
:warn
).
with
(
/Received invalid member/
)
expect
(
group
.
member_dns
).
not_to
include
(
'invalid,ou=user,ou=groups,dc=example,dc=com'
)
expect
(
group
.
member_dns
).
not_to
include
(
'invalid,ou=user,ou=groups,dc=example,dc=com'
)
end
end
...
...
lib/gitlab/auth/ldap/person.rb
View file @
a05820b8
...
@@ -45,7 +45,7 @@ module Gitlab
...
@@ -45,7 +45,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
.
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
dn
end
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