smengcl commented on code in PR #10760:
URL: https://github.com/apache/ozone/pull/10760#discussion_r4227241662


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -372,6 +423,15 @@ private void stopS3Gateway() throws Exception {
     }
   }
 
+  private void stopRecon() {
+    ReconServer service = reconServer;
+    reconServer = null;
+    if (service != null) {
+      service.stop();
+      service.join();

Review Comment:
   Calling `stop()` and `join()` here still leaves Recon's SCM-sync scheduler 
alive. `ReconStorageContainerManagerFacade.start()` creates a local 
`ScheduledExecutorService`, but its `stop()` never shuts that executor down. I 
reproduced a successful local S3/Recon run where `close()` and `main()` 
returned, but the non-daemon `Recon-SyncSCMContainerInfo-0` thread kept the JVM 
alive. Starting and closing Recon twice also leaves two of these threads.
   
   Please retain that scheduler as a field and shut it down in the facade's 
`stop()`. Suggested change in `ReconStorageContainerManagerFacade.java`:
   
   ```diff
   --- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
   +++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
   @@ -176,4 +176,5 @@
      private final ReconScmContainerSyncMetrics containerSyncMetrics;
      private final ExecutorService scmSnapshotExecutor;
   +  private ScheduledExecutorService scmContainerSyncScheduler;
      private final Object scmSnapshotLock = new Object();
      private Future<?> scmSnapshotFuture;
   @@ -588,5 +589,5 @@
              getDatanodeProtocolServer().getDatanodeRpcAddress()));
        }
   -    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1,
   +    scmContainerSyncScheduler = Executors.newScheduledThreadPool(1,
            new ThreadFactoryBuilder().setNameFormat(threadNamePrefix +
                                                         
"SyncSCMContainerInfo-%d")
   @@ -616,5 +617,5 @@
        LOG.debug("Started the SCM Container Info sync scheduler 
(interval={}ms, initialDelay={}ms).",
            syncInterval, syncInitialDelay);
   -    scheduler.scheduleWithFixedDelay(() -> {
   +    scmContainerSyncScheduler.scheduleWithFixedDelay(() -> {
          if (!isSyncDataFromSCMRunning.compareAndSet(false, true)) {
            LOG.debug("SCM container info sync is already running; skipping 
this cycle.");
   @@ -662,4 +663,7 @@
      @Override
      public void stop() {
   +    if (scmContainerSyncScheduler != null) {
   +      scmContainerSyncScheduler.shutdownNow();
   +    }
        getDatanodeProtocolServer().stop();
        reconScmTasks.forEach(ReconScmTask::stop);
   ```
   
   Please add a shutdown regression test that checks the scheduler terminates; 
a passing Surefire test alone can hide this leak when the fork exits.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -337,6 +365,23 @@ InetSocketAddress getS3gBoundAddress() {
     return s3Gateway != null ? s3Gateway.getHttpAddress() : null;
   }
 
+  @Override
+  public int getReconPort() {
+    if (!config.isReconEnabled()) {
+      return -1;
+    }
+    return preparedConfiguration == null ? config.getReconPort()
+        : preparedConfiguration.getReconPort();
+  }
+
+  @Override
+  public String getReconEndpoint() {
+    if (!config.isReconEnabled()) {
+      return "";
+    }
+    return "http://"; + getDisplayHost() + ":" + getReconPort();

Review Comment:
   This also affects startup: with `--no-s3g --recon` and 
`ozone.http.policy=HTTPS_ONLY`, configuration preparation succeeds and 
advertises an HTTP Recon endpoint even though the policy disables its HTTP 
listener. The readiness check then waits on that unbound HTTP port. I verified 
the prepared policy and endpoint; I did not run a full HTTPS startup with 
certificates.
   
   Since the local runtime already requires an HTTP listener for S3 Gateway, 
the smallest fix is to apply the same guard whenever Recon is enabled, before 
preparing storage:
   
   ```diff
   --- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java
   +++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java
   @@ -464,4 +464,11 @@
    
      private void configureLocalDefaults(OzoneConfiguration conf) throws 
IOException {
   +    if (config.isS3gEnabled() || config.isReconEnabled()) {
   +      HttpConfig.Policy httpPolicy =
   +          HttpConfig.Policy.fromString(conf.get(OZONE_HTTP_POLICY_KEY, 
OZONE_HTTP_POLICY_DEFAULT));
   +      if (httpPolicy != null && !httpPolicy.isHttpEnabled()) {
   +        rejectUserConfigured(conf, OZONE_HTTP_POLICY_KEY, "HTTP_ONLY or 
HTTP_AND_HTTPS");
   +      }
   +    }
        conf.set(OZONE_METADATA_DIRS, metadataDir().toString());
        // SCM and OM share one configuration and JVM, so the Jetty base dir is 
a
   @@ -711,10 +718,4 @@
        if (!config.isS3gEnabled()) {
          return -1;
   -    }
   -    // getS3Endpoint() advertises the HTTP listener, which a policy without 
HTTP leaves unbound.
   -    HttpConfig.Policy httpPolicy =
   -        HttpConfig.Policy.fromString(conf.get(OZONE_HTTP_POLICY_KEY, 
OZONE_HTTP_POLICY_DEFAULT));
   -    if (httpPolicy != null && !httpPolicy.isHttpEnabled()) {
   -      rejectUserConfigured(conf, OZONE_HTTP_POLICY_KEY, "HTTP_ONLY or 
HTTP_AND_HTTPS");
        }
        // getS3gPort() reads the port back off this listener.
   ```
   
   Please cover the Recon-only HTTPS_ONLY configuration in 
`TestLocalOzoneCluster`.



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