[ 
https://issues.apache.org/jira/browse/HDFS-17947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18100123#comment-18100123
 ] 

ASF GitHub Bot commented on HDFS-17947:
---------------------------------------

joseluisll commented on code in PR #8638:
URL: https://github.com/apache/hadoop/pull/8638#discussion_r3675486534


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockTokenWithDFS.java:
##########
@@ -222,6 +224,26 @@ protected Configuration getConf(int numDataNodes) {
     return conf;
   }
 
+  /**
+   * A non-positive block token lifetime makes every block token expire at the
+   * instant it is created, so it must be rejected instead of failing later on
+   * every write pipeline.
+   */
+  @Test
+  public void testInvalidBlockTokenLifetime() {
+    for (long lifetime : new long[] {0, -1}) {
+      Configuration conf = getConf(1);
+      conf.setLong(DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY, 
lifetime);
+      HadoopIllegalArgumentException e = assertThrows(
+          HadoopIllegalArgumentException.class,
+          () -> new MiniDFSCluster.Builder(conf).numDataNodes(1).build());
+      assertTrue(
+          e.getMessage().contains(
+              DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY),
+          "unexpected message: " + e.getMessage());
+    }

Review Comment:
   Done, folded into the assertThrows call.



##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockTokenWithDFS.java:
##########
@@ -222,6 +224,26 @@ protected Configuration getConf(int numDataNodes) {
     return conf;
   }
 
+  /**
+   * A non-positive block token lifetime makes every block token expire at the
+   * instant it is created, so it must be rejected instead of failing later on
+   * every write pipeline.
+   */
+  @Test

Review Comment:
   Done, javadoc removed to match the rest of the class.





>  dfs.block.access.token.lifetime=0 can cause DataStreamer 
> createBlockOutputStream failure
> -----------------------------------------------------------------------------------------
>
>                 Key: HDFS-17947
>                 URL: https://issues.apache.org/jira/browse/HDFS-17947
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs-client
>    Affects Versions: 3.4.3
>            Reporter: jiang he
>            Priority: Major
>              Labels: pull-request-available
>
> When block access tokens are enabled and dfs.block.access.token.lifetime is
>   set to 0, HDFS write operations fail with a DataStreamer error.
>   Reproduced with Hadoop 3.4.3.
>   The same test passes when dfs.block.access.token.lifetime is set to a normal
>   positive value.
>   Reproduction config
>   <configuration>
>     <property>
>       <name>dfs.replication</name>
>       <value>1</value>
>     </property>
>     <property>
>       <name>dfs.datanode.du.reserved.calculator</name>
>       
> <value>org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.ReservedSpaceCalculator$ReservedSpaceCalculatorAbsolu
>   te</value>
>     </property>
>     <property>
>       <name>dfs.block.access.token.lifetime</name>
>       <value>0</value>
>     </property>
>     <property>
>       <name>dfs.namenode.upgrade.domain.factor</name>
>       <value>${dfs.replication}</value>
>     </property>
>     <property>
>       <name>dfs.ha.zkfc.nn.http.timeout.ms</name>
>       <value>20000</value>
>     </property>
>     <property>
>       <name>dfs.namenode.reencrypt.throttle.limit.updater.ratio</name>
>       <value>1.0</value>
>     </property>
>     <property>
>       <name>dfs.namenode.redundancy.considerLoadByVolume</name>
>       <value>false</value>
>     </property>
>     <property>
>       <name>dfs.datanode.du.reserved</name>
>       <value>0</value>
>     </property>
>     <property>
>       <name>dfs.datanode.du.reserved.pct</name>
>       <value>0</value>
>     </property>
>     <property>
>       <name>dfs.block.access.token.enable</name>
>       <value>True</value>
>     </property>
>     <property>
>       <name>dfs.replication</name>
>       <value>3</value>
>     </property>
>     <property>
>       <name>dfs.namenode.reencrypt.throttle.limit.handler.ratio</name>
>       <value>1.0</value>
>     </property>
>   </configuration>
>   Observed
>   WARN hdfs.DataStreamer:
>   Exception in createBlockOutputStream blk_1073741825_1001
>   The API test fails while writing to HDFS.
>   Full observed wrapper output:
>   API operation exception and shut done hdfs!
>   Exception in thread "main" java.lang.RuntimeException:
>   API request Exception: Operation exception[info_excetion]
>   2026-06-26 15:59:40,444 WARN hdfs.DataStreamer:
>   Exception in createBlockOutputStream blk_1073741825_1001
>   Expected
>   Either dfs.block.access.token.lifetime=0 should be rejected with a clear
>   configuration validation error, or HDFS should handle this value without
>   causing DataStreamer write failure.
>   Control test
>   dfs.block.access.token.enable=true
>   dfs.block.access.token.lifetime=600
>   passes successfully.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to