You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2020/11/17 14:57:16 UTC

[hadoop] branch branch-3.3 updated: HADOOP-17379. AbstractS3ATokenIdentifier to set issue date == now. (#2466)

This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 22039a1  HADOOP-17379. AbstractS3ATokenIdentifier to set issue date == now. (#2466)
22039a1 is described below

commit 22039a14ff2b9d280f71b0735c32e6ac717e2344
Author: Jungtaek Lim <ka...@gmail.com>
AuthorDate: Tue Nov 17 23:43:29 2020 +0900

    HADOOP-17379. AbstractS3ATokenIdentifier to set issue date == now. (#2466)
    
    Unless you explicitly set it, the issue date of a delegation token identifier is 0, which confuses spark renewal (SPARK-33440). This patch makes sure that all S3A DT identifiers have the current time as issue date, fixing the problem as far as S3A tokens are concerned.
    
    Contributed by Jungtaek Lim.
    
    Change-Id: Ic80ac7895612a1aa669459c73a78a9c17ecf0c0d
---
 .../fs/s3a/auth/delegation/AbstractS3ATokenIdentifier.java    |  9 +++++++++
 .../fs/s3a/auth/delegation/TestS3ADelegationTokenSupport.java | 11 +++++++++++
 2 files changed, 20 insertions(+)

diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/AbstractS3ATokenIdentifier.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/AbstractS3ATokenIdentifier.java
index c86134e..f859f47 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/AbstractS3ATokenIdentifier.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/AbstractS3ATokenIdentifier.java
@@ -24,6 +24,7 @@ import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.net.URI;
+import java.time.Clock;
 import java.util.Objects;
 import java.util.UUID;
 
@@ -140,6 +141,7 @@ public abstract class AbstractS3ATokenIdentifier
       final URI uri) {
     super(kind, owner, renewer, realUser);
     this.uri = requireNonNull(uri);
+    initializeIssueDate();
   }
 
   /**
@@ -164,6 +166,13 @@ public abstract class AbstractS3ATokenIdentifier
    */
   protected AbstractS3ATokenIdentifier(final Text kind) {
     super(kind);
+    initializeIssueDate();
+  }
+
+  private void initializeIssueDate() {
+    Clock clock = Clock.systemDefaultZone();
+    long now = clock.millis();
+    setIssueDate(now);
   }
 
   public String getBucket() {
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/delegation/TestS3ADelegationTokenSupport.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/delegation/TestS3ADelegationTokenSupport.java
index 516022e..88d9ebf 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/delegation/TestS3ADelegationTokenSupport.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/delegation/TestS3ADelegationTokenSupport.java
@@ -38,6 +38,7 @@ import static org.apache.hadoop.fs.s3a.auth.delegation.DelegationConstants.SESSI
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Unit tests related to S3A DT support.
@@ -59,6 +60,14 @@ public class TestS3ADelegationTokenSupport {
   }
 
   @Test
+  public void testSessionTokenIssueDate() throws Throwable {
+    AbstractS3ATokenIdentifier identifier
+        = new SessionTokenIdentifier();
+    assertEquals(SESSION_TOKEN_KIND, identifier.getKind());
+    assertTrue("issue date is not set", identifier.getIssueDate() > 0L);
+  }
+
+  @Test
   public void testSessionTokenDecode() throws Throwable {
     Text alice = new Text("alice");
     Text renewer = new Text("yarn");
@@ -90,6 +99,8 @@ public class TestS3ADelegationTokenSupport {
         UserGroupInformation.AuthenticationMethod.TOKEN,
         decodedUser.getAuthenticationMethod());
     assertEquals("origin", decoded.getOrigin());
+    assertEquals("issue date", identifier.getIssueDate(),
+        decoded.getIssueDate());
   }
 
   @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org