You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "smengcl (via GitHub)" <gi...@apache.org> on 2026/08/12 03:53:43 UTC

[PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

smengcl opened a new pull request, #10997:
URL: https://github.com/apache/ozone/pull/10997

   Generated-by: Claude Code (Opus 4.8)
   
   ## What changes were proposed in this pull request?
   
   `HttpServer2.setHttpBaseDir()` creates the temporary HTTP base directory under the process current working directory when `ozone.http.basedir` is unset:
   
   ```java
   File tmpMetaDir = Files.createTempDirectory(Paths.get(""), "ozone_http_tmp_base_dir").toFile();
   ```
   
   `Paths.get("")` resolves to the process working directory. When that directory is not writable by the running uid, `Files.createTempDirectory` throws `AccessDeniedException`, which `GenericCli` reports as `Access denied: ...` and the process exits.
   
   S3 Gateway is the service that hits this: `Gateway.call()` invokes the static `setHttpBaseDir()` at startup, before its HTTP servers are constructed. In the `kubernetes` acceptance check the s3g statefulset sets no `workingDir` and no `runAsUser`, so the working directory is the runner image working directory; when it is not writable the s3g pod CrashLoopBackOffs at startup, before serving anything. SCM, OM, Recon and Datanode are not affected: they do not call the static helper, and `BaseHttpServer` resolves an unset `ozone.http.basedir` to `${ozone.metadata.dirs}/webserver` on a writable volume. The docker-compose environments are not affected because they set `ozone.http.basedir=/tmp/ozone_http` explicitly.
   
   This changes `setHttpBaseDir()` to create the temporary base directory under `java.io.tmpdir` (`Files.createTempDirectory("ozone_http_tmp_base_dir")`), which is writable by contract, so startup no longer depends on the working directory being writable. Freon uses the same helper and benefits from the same fix.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16156
   
   ## How was this patch tested?
   
   Added `TestHttpServer2#testSetHttpBaseDirUsesSystemTempDir`, which asserts that the resolved base directory exists and is located under `java.io.tmpdir`. Ran the new test and `checkstyle` on the `framework` module locally; both pass.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl commented on code in PR #10997:
URL: https://github.com/apache/ozone/pull/10997#discussion_r4032725984


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/server/http/TestHttpServer2.java:
##########
@@ -50,4 +54,25 @@ public void testIdleTimeout() throws Exception {
       assertEquals(60000, server.getIdleTimeout());
     }
   }
+
+  /**
+   * When ozone.http.basedir is not set, the base dir must be created under the
+   * system temporary directory (java.io.tmpdir), not the process working
+   * directory, so startup does not fail when the CWD is not writable.
+   */
+  @Test
+  public void testSetHttpBaseDirUsesSystemTempDir() throws Exception {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.unset(OzoneConfigKeys.OZONE_HTTP_BASEDIR);
+
+    HttpServer2.setHttpBaseDir(conf);
+
+    String baseDir = conf.get(OzoneConfigKeys.OZONE_HTTP_BASEDIR);
+    assertThat(baseDir).isNotEmpty();
+    Path baseDirPath = Paths.get(baseDir).toAbsolutePath().normalize();
+    assertThat(baseDirPath).exists();
+    Path systemTmpDir = Paths.get(System.getProperty("java.io.tmpdir"))
+        .toAbsolutePath().normalize();
+    assertThat(baseDirPath.startsWith(systemTmpDir)).isTrue();

Review Comment:
   Sure. Added in fed5fa85c3f782b574b5197b04e1f3aea7ab2392



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10997:
URL: https://github.com/apache/ozone/pull/10997#issuecomment-5518265403

   This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10997:
URL: https://github.com/apache/ozone/pull/10997#issuecomment-5627242210

   Thank you for your contribution. This PR is being closed due to inactivity. Please contact a maintainer if you would like to reopen it.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl commented on PR #10997:
URL: https://github.com/apache/ozone/pull/10997#issuecomment-5716666363

   Thanks @yandrey321 @jojochuang for the reviews.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "smengcl (via GitHub)" <gi...@apache.org>.
smengcl merged PR #10997:
URL: https://github.com/apache/ozone/pull/10997


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "yandrey321 (via GitHub)" <gi...@apache.org>.
yandrey321 commented on code in PR #10997:
URL: https://github.com/apache/ozone/pull/10997#discussion_r4007711389


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/server/http/TestHttpServer2.java:
##########
@@ -50,4 +54,25 @@ public void testIdleTimeout() throws Exception {
       assertEquals(60000, server.getIdleTimeout());
     }
   }
+
+  /**
+   * When ozone.http.basedir is not set, the base dir must be created under the
+   * system temporary directory (java.io.tmpdir), not the process working
+   * directory, so startup does not fail when the CWD is not writable.
+   */
+  @Test
+  public void testSetHttpBaseDirUsesSystemTempDir() throws Exception {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.unset(OzoneConfigKeys.OZONE_HTTP_BASEDIR);
+
+    HttpServer2.setHttpBaseDir(conf);
+
+    String baseDir = conf.get(OzoneConfigKeys.OZONE_HTTP_BASEDIR);
+    assertThat(baseDir).isNotEmpty();
+    Path baseDirPath = Paths.get(baseDir).toAbsolutePath().normalize();
+    assertThat(baseDirPath).exists();
+    Path systemTmpDir = Paths.get(System.getProperty("java.io.tmpdir"))
+        .toAbsolutePath().normalize();
+    assertThat(baseDirPath.startsWith(systemTmpDir)).isTrue();

Review Comment:
   do we have a test that only ozone user can write to this folder?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #10997: HDDS-16156. Create HTTP base dir under java.io.tmpdir instead of the working directory
URL: https://github.com/apache/ozone/pull/10997


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org