LDAP sync fails on deleted directory user
Overview
When syncing LDAP user in GitLab v9.2.7>9.3.0 that has been removed the LDAP directory the sync throws an exception.
Exception
v9.3.0 - https://gitlab.com/gitlab-org/gitlab-ee/blob/v9.3.0-ee/lib/gitlab/ldap/access.rb#L189
undefined method `group_cns' for ["mail", "email", "userPrincipalName"]:Array
Did you mean? group_by
v9.2.7
NoMethodError: undefined method `dn' for ["mail", "email", "userPrincipalName"]:Array
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:170:in `update_identity'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:102:in `update_user'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:22:in `block in allowed?'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:13:in `block in open'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/adapter.rb:14:in `block in open'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:616:in `block in open'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:685:in `block in open'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.12.1/lib/net/ldap/instrumentation.rb:19:in `instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:680:in `open'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:616:in `open'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/adapter.rb:13:in `open'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:12:in `open'
from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/access.rb:18:in `allowed?'
from (irb):74:in `block in irb_binding'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/batches.rb:51:in `each'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/batches.rb:51:in `block in find_each'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/batches.rb:124:in `find_in_batches'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/batches.rb:50:in `find_each'
from (irb):70:in `each'
from (irb):70
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:110:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:9:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68:in `console'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>'
Edited by Chris