-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuration of read/connect timeout in LDAP client #10925
Allow configuration of read/connect timeout in LDAP client #10925
Conversation
9bec775
to
64ba2c0
Compare
7c7049c
to
637f826
Compare
DisposableSubContext ignored = openLdapServer.createUser(organization, "alice", "alice-pass")) { | ||
LdapConfig ldapConfig = new LdapConfig() | ||
.setLdapUrl(openLdapServer.getLdapUrl()) | ||
.setLdapConnectTimeout(new Duration(1, MILLISECONDS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to control how long the server gets to respond? Otherwise it looks like it's based on luck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we cannot configure the server to provide a timeout.
Otherwise it looks like it's based on luck
True, but ran it around 1k times it wasn't failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we see flakiness due to this - we could use toxyproxy to increase the latency for queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer preventing flakiness rather than fixing, though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well in case of connection timeout we can just create some artificial service that will open socket (ServerSocket should do) but will never respond. That will cause connection timeout for 100%.
Same for read timeout we just need to response with welcome package and afterwards nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aczajkowski Have used ToxiProxy which adds latency for these tests thereby failing due to read and connect timeouts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok makes the job. Java server socket will be just more lightweight. But will be possibly hard to emulate ldap welcome response (no idea to be honest)
@ksobolew Have used ToxiProxy to make sure there is a latency, now we could have a way to ensure that connect timeout happens always. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
DisposableSubContext ignored = openLdapServer.createUser(organization, "alice", "alice-pass")) { | ||
LdapConfig ldapConfig = new LdapConfig() | ||
.setLdapUrl(openLdapServer.getLdapUrl()) | ||
.setLdapConnectTimeout(new Duration(1, MILLISECONDS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well in case of connection timeout we can just create some artificial service that will open socket (ServerSocket should do) but will never respond. That will cause connection timeout for 100%.
Same for read timeout we just need to response with welcome package and afterwards nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc content looks good,.
...ssword-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapAuthenticator.java
Outdated
Show resolved
Hide resolved
...in/trino-password-authenticators/src/main/java/io/trino/plugin/password/ldap/LdapConfig.java
Outdated
Show resolved
Hide resolved
...ssword-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapAuthenticator.java
Outdated
Show resolved
Hide resolved
...ssword-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapAuthenticator.java
Outdated
Show resolved
Hide resolved
LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(new JdkLdapAuthenticatorClient(ldapConfig), ldapConfig); | ||
assertThatThrownBy(() -> ldapAuthenticator.createAuthenticatedPrincipal("alice", "alice-pass")) | ||
.isInstanceOf(RuntimeException.class) | ||
.hasMessageMatching(".*Authentication error.*"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no difference as in tests above. As I understood you before authentication error is raised on connection timeout. Here I was expecting some timeout exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But LDAPClient doesn't throw much of a granular exception, so I guess it would throw something similar to Authentication error
021a641
to
3be01cc
Compare
@kokosing AC |
3be01cc
to
57e4bb0
Compare
57e4bb0
to
10158c9
Compare
No description provided.