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


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml:
##########
@@ -650,7 +650,12 @@
 <property>
   <name>dfs.block.access.token.lifetime</name>
   <value>600</value>
-  <description>The lifetime of access tokens in minutes.</description>
+  <description>The lifetime of access tokens in minutes. Must be greater than
+    zero. A non-positive value makes every block access token expire at the
+    instant it is created, which causes DataNodes to reject them and all write
+    pipelines to fail. When block access tokens are enabled, the NameNode
+    rejects a non-positive value and will neither format nor start.
+  </description>

Review Comment:
   no need to change the description here



##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java:
##########
@@ -722,8 +722,17 @@ private static BlockTokenSecretManager 
createBlockTokenSecretManager(
         DFSConfigKeys.DFS_BLOCK_ACCESS_KEY_UPDATE_INTERVAL_KEY, 
         DFSConfigKeys.DFS_BLOCK_ACCESS_KEY_UPDATE_INTERVAL_DEFAULT);
     final long lifetimeMin = conf.getLong(
-        DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY, 
+        DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY,
         DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_DEFAULT);
+    if (lifetimeMin <= 0) {
+      throw new HadoopIllegalArgumentException(
+          DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY + " = "
+              + lifetimeMin + " is invalid. It must be a positive number of"
+              + " minutes. A non-positive lifetime makes every block access"
+              + " token expire at the instant it is created, so DataNodes"
+              + " reject all of them and no write pipeline can be"
+              + " established.");
+    }

Review Comment:
   This is too much information, just telling it is invalid and should be +ve 
is more than enoguh



##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/token/block/TestBlockTokenZeroLifetime.java:
##########
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.security.token.block;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.EnumSet;
+
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
+import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.security.token.Token;
+import org.apache.hadoop.util.Time;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests the behaviour of {@link BlockTokenSecretManager} when it is configured
+ * with a token lifetime of zero, which is what
+ * {@code dfs.block.access.token.lifetime = 0} produces (HDFS-17947).
+ *
+ * A zero lifetime makes every token expire at the instant it is minted, so it
+ * is rejected by the very next verification. These tests pin that behaviour
+ * down at the secret-manager level, without needing a cluster.
+ */
+public class TestBlockTokenZeroLifetime {

Review Comment:
   adjust somewhere in a related exisiting test rather than adding a new class



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