This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new f12e856a Retry if bind cannot contact server
f12e856a is described below
commit f12e856a38183b41ebe4389500c6bd23c9c3cd47
Author: Sebb <[email protected]>
AuthorDate: Fri Oct 4 22:48:03 2024 +0100
Retry if bind cannot contact server
---
lib/whimsy/asf/ldap.rb | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 0e41194b..90b210df 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -105,20 +105,30 @@ module ASF
end
dn = ASF::Person.new(user).dn
- raise ::LDAP::ResultError.new('Unknown user') unless dn
begin
@ldap.unbind if @ldap&.bound?
rescue StandardError
# ignore
end
- ldap = ASF._init_ldap(true, self.rwhosts)
- if block
- ASF.flush_weakrefs
- ldap.bind(dn, password, &block)
- ASF._init_ldap(true)
- else
- ldap.bind(dn, password)
+ self.rwhosts.each do |rwhost|
+ begin
+ ldap = ASF._init_ldap(true, [rwhost])
+ if block
+ ASF.flush_weakrefs
+ ldap.bind(dn, password, &block)
+ ASF._init_ldap(true)
+ else
+ ldap.bind(dn, password)
+ end
+ break
+ rescue ::LDAP::ResultError => e
+ if e.message == "Can't contact LDAP server" # Any others worth a
retry?
+ Wunderbar.warn "#{rwhost}: #{e.inspect}, continuing"
+ else
+ raise
+ end
+ end
end
ensure
ASF.flush_weakrefs