You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "adityaanikam (via GitHub)" <gi...@apache.org> on 2026/09/29 09:01:50 UTC
[PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
adityaanikam opened a new pull request, #3185:
URL: https://github.com/apache/helix/pull/3185
Fixes #3184
`isKerberosAuthEnabled`, added in #3102 to fix #3101, decides whether `waitUntilConnected` should wait for `SaslAuthenticated` instead of `SyncConnected`. It only recognizes `Krb5LoginModule`. When a ZooKeeper server requires SASL client authentication (`sessionRequireClientSASLAuth=true`), a DIGEST-MD5 client reaches `SaslAuthenticated` the same way a Kerberos client does, and `SyncConnected` never follows, so `waitUntilConnected` still waits for the wrong state and the controller or participant times out, even though authentication itself succeeded.
This extracts the login module check into a small `isSaslAuthLoginModule(String)` predicate and extends it to also match `DigestLoginModule`, so a DIGEST-MD5 session waits for the same terminal state a Kerberos session already does. Kerberos behavior, the method's existing three tests, and every other caller are unchanged.
Testing: added `testIsSaslAuthLoginModule_DetectsKerberosAndDigest`, testing the extracted predicate directly against a Kerberos module name, a Digest module name, and a non-SASL module name. Routing this through a live `ZkClient` connection against the local non-SASL test server (mirroring the existing three tests' pattern) turned out to be unreliable specifically for the Digest module, hanging until the connection timeout rather than failing fast, so the new test exercises the predicate directly instead. Ran `TestZkClientKerberos` alone (4 passed) and the full `zookeeper-api` module test suite (104 passed, 0 failures).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "adityaanikam (via GitHub) via reviews" <re...@helix.apache.org>.
adityaanikam commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6722299826
Thanks for the detailed review. I pushed ca9d35b.
1. waitUntilConnected now also accepts SyncConnected when ZooKeeper has no SASL client or its client failed. In ZooKeeper 3.6.3 a failed login leaves getSaslClient() null and the client connects without SASL, so I check for null as well as isFailed(). A new test uses a login module that always fails: it times out without the change and passes with it.
2. I rewrote the description to match the mechanism you described.
3. The test points are done: the property and registry reset are inside the try, the server sets sessionRequireClientSASLAuth, getRandomPort() is used, the disabled test sets zookeeper.sasl.client=false, the module tests share a data provider, and the class is now TestZkClientSasl.
The full zookeeper-api module passes (106 tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "junkaixue (via GitHub)" <gi...@apache.org>.
junkaixue commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6175747768
This logic hard-codes only Krb5LoginModule and DigestLoginModule as SASL authentication. ZooKeeper clients can use a custom or wrapped JAAS LoginModule; in that case, SASL may still complete and emit SaslAuthenticated, but this method returns false and waitUntilConnected() waits for SyncConnected instead. That can reintroduce the connection timeout this change is trying to fix.
Can we determine the expected connection state from whether client SASL is enabled/configured, rather than from a substring match on two specific login-module class names? At minimum, please add coverage for a non-built-in/custom login-module configuration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "ReiValera (via GitHub)" <gi...@apache.org>.
ReiValera commented on code in PR #3185:
URL: https://github.com/apache/helix/pull/3185#discussion_r4134956462
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
Review Comment:
Should this method name change now?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "junkaixue (via GitHub) via reviews" <re...@helix.apache.org>.
junkaixue commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6712633347
Thanks for the integration test and for grounding the check in how `ZooKeeperSaslClient` itself decides to attempt SASL. That resolves my earlier concern about matching on module class names. A couple of follow-ups before I approve:
**1. Behavior when SASL is configured but login fails (non-blocking, but let's decide explicitly)**
`ClientCnxn.startConnect` catches `LoginException` from building the SASL client (missing keytab, expired ticket cache, unloadable custom module), queues `AuthFailed`, and continues connecting without SASL "if the server allows it". In that case the session still reaches `SyncConnected` and is usable, but `_currentState` never becomes `SaslAuthenticated`, so `connect()` waits for the full timeout and throws `ZkTimeoutException`. Before #3102 that degraded connection worked. #3102 changed it for Kerberos only. This PR extends the fail-fast to every SASL module.
Failing fast may well be the right choice, but it is a behavior change beyond the bug fix. Have `waitUntilConnected()` also accept `SyncConnected` when the underlying `ZooKeeper.getSaslClient()` reports `isFailed()`. Helix relies a lot on ZK behaviors.
**2. PR description does not match the actual mechanism**
The description says `SyncConnected` "never follows". ZooKeeper always emits `SyncConnected` first on connect; `SaslAuthenticated` then overwrites `_currentState`. The bug is that any later `waitUntilConnected()` call (reconnect, `retryUntilConnected` after a connection loss, or a race on the initial connect) compares against a state that has already been replaced. Your comment on the integration test describes this correctly. Please update the description, since it becomes the squash commit message.
**3. Test nits**
- `testConnectsToDigestSaslServer`: `System.setProperty("zookeeper.authProvider.1", ...)` and `ProviderRegistry.reset()` run before the `try`, so if `new ZooKeeperServer(...)` throws, the JVM-global registry and property leak into later tests. Move them inside the `try`.
- Consider setting `zookeeper.sessionRequireClientSASLAuth=true` on the test server so it matches the scenario in #3184. The test is still a valid regression test without it.
- Use `TestHelper.getRandomPort()` instead of the `ServerSocket(0)` block, consistent with `TestRawZkClient`.
- `testIsSaslAuthEnabled_WhenSaslDisabled`: `zookeeper.sasl.client` defaults to `true`, so SASL is not disabled here; the method returns false because there is no `Client` JAAS entry. Either set the property to `false` explicitly or rename the test.
- The DIGEST and custom-module predicate tests differ only by module name; a `@DataProvider` would collapse them.
- The class name `TestZkClientKerberos` now covers DIGEST and custom modules too. `TestZkClientSasl` would be more accurate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "ReiValera (via GitHub)" <gi...@apache.org>.
ReiValera commented on code in PR #3185:
URL: https://github.com/apache/helix/pull/3185#discussion_r4134956462
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
Review Comment:
Should this method name change now? Same with the Javadoc for the return statement
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "adityaanikam (via GitHub) via reviews" <re...@helix.apache.org>.
adityaanikam commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-7216093640
Done in b19b4e1: only the null check is left, and I trimmed "or it failed" from the Javadoc and the description. The zookeeper-api tests pass (106, 0 failures).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "junkaixue (via GitHub) via reviews" <re...@helix.apache.org>.
junkaixue commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6758928490
Thanks, ca9d35b covers everything from the last round, and I verified TestZkClientSasl passes when merged onto current master (ZooKeeper 3.9.3).
One last change, and it corrects my own earlier suggestion: please drop the || saslClient.isFailed() half of isSaslSkipped() and keep only the null check you added. When the SASL client is in the failed state, ClientCnxn moves the session to AUTH_FAILED, so that session is never usable. Accepting SyncConnected there only lets connect() return a dead client in the window before the AuthFailed event is processed. I reproduced that with a Client JAAS entry whose login succeeds but produces no SASL client: build() returns with zkState=AUTH_FAILED. With only the null check it times out with ZkTimeoutException, and your tests still pass. Please also trim "or it failed" from the Javadoc and the PR description.
LGTM once that is in.
Also, I triggered the approval workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "adityaanikam (via GitHub)" <gi...@apache.org>.
adityaanikam commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6396560490
Thanks, I added the integration test in 4b63a5a.
It starts a ZooKeeper server that requires DIGEST SASL, builds the client with SASL already configured, and checks that the client connects. It then waits for SaslAuthenticated and checks that waitUntilConnected() returns.
With the fix, the five tests in TestZkClientKerberos pass. With waitUntilConnected() expecting SyncConnected again, as before the fix, the new test fails. On a local server the client sees SyncConnected before SaslAuthenticated replaces it, so building the client alone passes either way. The waitUntilConnected() call after SaslAuthenticated is what makes the old behavior fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "adityaanikam (via GitHub)" <gi...@apache.org>.
adityaanikam commented on PR #3185:
URL: https://github.com/apache/helix/pull/3185#issuecomment-6221797621
Thanks, that makes sense. I checked how ZooKeeper decides this: ZooKeeperSaslClient builds its SASL client whenever the JAAS config has an entry for the client context, whatever login module that entry names, and clientTunneledAuthenticationInProgress() uses the same check. So the module class name is not what decides it.
I removed the Krb5LoginModule/DigestLoginModule match. isSaslAuthEnabled() now returns true when the SASL client is enabled and the JAAS config has an entry for the client context. I also replaced the predicate test with tests for a DIGEST module and a custom module. They enable SASL after the client is built, because with SASL expected a live connection to the non-SASL test server would wait for a SaslAuthenticated event that never arrives.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
Re: [PR] Fix ZkClient timeout after SASL DIGEST-MD5 authentication [helix]
Posted by "adityaanikam (via GitHub)" <gi...@apache.org>.
adityaanikam commented on code in PR #3185:
URL: https://github.com/apache/helix/pull/3185#discussion_r4155350354
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
Review Comment:
Good point, the method covers DIGEST as well now, so I renamed it to isSaslAuthEnabled and updated its javadoc (including the @return), the log message, and the tests that reach it by reflection. Pushed as a separate commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org