pan3793 commented on code in PR #8688:
URL: https://github.com/apache/hadoop/pull/8688#discussion_r3912672644


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -386,6 +409,20 @@ private void loadFromZKCache(final boolean isTokenCache) {
     LOG.info("Loaded {} cache.", cacheName);
   }
 
+  private void awaitCacheInitialized(CountDownLatch initialized,
+      String cacheName) throws IOException {
+    try {
+      if (!initialized.await(CACHE_INITIALIZED_TIMEOUT_SECONDS, 
TimeUnit.SECONDS)) {

Review Comment:
   Made configurable via `zk-dt-secret-manager.zkCacheInitTimeout` (ms) in 
f35a83a. Default 0 waits indefinitely; the tests set 10s.



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestZKDelegationTokenSecretManager.java:
##########
@@ -522,6 +522,13 @@ public Boolean get() {
 
     // The good token should be loaded on startup, and removed after expiry.
     id = smNew.decodeTokenIdentifier(token);
+    final AbstractDelegationTokenIdentifier idGood = id;
+    GenericTestUtils.waitFor(new Supplier<Boolean>() {

Review Comment:
   Restored the immediate assertion after `tm.init()` in f35a83a. The trunk 
failure linked above fails on exactly this assertion without the production 
change.



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -301,9 +310,11 @@ public void startThreads() throws IOException {
             }
           })
           .forDeletes(childData -> processKeyRemoved(childData.getPath()))
+          .forInitialized(keyCacheInitialized::countDown)
           .build();
       keyCache.listenable().addListener(keyCacheListener);
       keyCache.start();
+      awaitCacheInitialized(keyCacheInitialized, "key");

Review Comment:
   `startThreads()` now calls `stopThreads()` before rethrowing on any failure, 
with an `isRunning()` guard so the cleanup never stops a running instance, in 
f35a83a.



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -333,9 +349,11 @@ public void startThreads() throws IOException {
                 throw new UncheckedIOException(e);
               }
             })
+            .forInitialized(tokenCacheInitialized::countDown)
             .build();
         tokenCache.listenable().addListener(tokenCacheListener);
         tokenCache.start();
+        awaitCacheInitialized(tokenCacheInitialized, "token");

Review Comment:
   Same as above, fixed in f35a83a.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to