Skip to content
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

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

Praveen2112
Copy link
Member

@Praveen2112 Praveen2112 commented Feb 3, 2022

No description provided.

@cla-bot cla-bot bot added the cla-signed label Feb 3, 2022
@Praveen2112 Praveen2112 force-pushed the praveen/with_custom_config branch 2 times, most recently from 9bec775 to 64ba2c0 Compare February 3, 2022 08:45
@github-actions github-actions bot added the docs label Feb 3, 2022
@Praveen2112 Praveen2112 force-pushed the praveen/with_custom_config branch 4 times, most recently from 7c7049c to 637f826 Compare February 9, 2022 12:29
@Praveen2112 Praveen2112 marked this pull request as ready for review February 9, 2022 12:29
DisposableSubContext ignored = openLdapServer.createUser(organization, "alice", "alice-pass")) {
LdapConfig ldapConfig = new LdapConfig()
.setLdapUrl(openLdapServer.getLdapUrl())
.setLdapConnectTimeout(new Duration(1, MILLISECONDS))
Copy link
Contributor

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

Copy link
Member Author

@Praveen2112 Praveen2112 Feb 9, 2022

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

Copy link
Member Author

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.

Copy link
Contributor

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 :)

Copy link
Member

@aczajkowski aczajkowski Feb 9, 2022

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.

Copy link
Member Author

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.

Copy link
Member

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)

@Praveen2112
Copy link
Member Author

@ksobolew Have used ToxiProxy to make sure there is a latency, now we could have a way to ensure that connect timeout happens always.

Copy link
Member

@aczajkowski aczajkowski left a 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))
Copy link
Member

@aczajkowski aczajkowski Feb 9, 2022

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.

Copy link
Member

@mosabua mosabua left a 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,.

docs/src/main/sphinx/security/ldap.rst Show resolved Hide resolved
LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(new JdkLdapAuthenticatorClient(ldapConfig), ldapConfig);
assertThatThrownBy(() -> ldapAuthenticator.createAuthenticatedPrincipal("alice", "alice-pass"))
.isInstanceOf(RuntimeException.class)
.hasMessageMatching(".*Authentication error.*");
Copy link
Member

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.

Copy link
Member Author

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

@Praveen2112 Praveen2112 force-pushed the praveen/with_custom_config branch from 021a641 to 3be01cc Compare February 14, 2022 13:43
@Praveen2112
Copy link
Member Author

@kokosing AC

@Praveen2112 Praveen2112 force-pushed the praveen/with_custom_config branch from 3be01cc to 57e4bb0 Compare February 21, 2022 14:16
@Praveen2112 Praveen2112 force-pushed the praveen/with_custom_config branch from 57e4bb0 to 10158c9 Compare February 25, 2022 06:20
@Praveen2112 Praveen2112 merged commit 04ef924 into trinodb:master Feb 25, 2022
@github-actions github-actions bot added this to the 372 milestone Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants