hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sj...@apache.org
Subject [1/2] hadoop git commit: HDFS-7530. Allow renaming of encryption zone roots. Contributed by Charles Lamb.
Date Wed, 21 Sep 2016 00:48:01 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.6 2010dd302 -> 3a75b446e
  refs/heads/branch-2.6.5 7df143869 -> 18d38cdd6


HDFS-7530. Allow renaming of encryption zone roots. Contributed by Charles Lamb.

(cherry picked from commit b0b9084433d5e80131429e6e76858b099deb2dda)
(cherry picked from commit 8d98d87745374090d83437705c928ab18c0b895a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/18d38cdd
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/18d38cdd
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/18d38cdd

Branch: refs/heads/branch-2.6.5
Commit: 18d38cdd631d0aba0a0fb0d5851e57d9da7a9ee4
Parents: 7df1438
Author: Andrew Wang <wang@apache.org>
Authored: Thu Dec 18 14:06:53 2014 -0800
Committer: Sangjin Lee <sjlee@apache.org>
Committed: Tue Sep 20 17:46:07 2016 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  2 ++
 .../server/namenode/EncryptionZoneManager.java  |  4 +++
 .../apache/hadoop/hdfs/TestEncryptionZones.java | 13 +++++++++
 .../src/test/resources/testCryptoConf.xml       | 30 +++++++++++++++++---
 4 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/18d38cdd/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index d66d5c2..e18b40c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -53,6 +53,8 @@ Release 2.6.5 - UNRELEASED
     HDFS-10763. Open files can leak permanently due to inconsistent
     lease update (kihwal)
 
+    HDFS-7530. Allow renaming of encryption zone roots. (Charles Lamb via wang)
+
 Release 2.6.4 - 2016-02-11
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18d38cdd/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java
index 16ff864..73eb957 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java
@@ -260,6 +260,10 @@ public class EncryptionZoneManager {
     final boolean dstInEZ = (dstEZI != null);
     if (srcInEZ) {
       if (!dstInEZ) {
+        if (srcEZI.getINodeId() == srcIIP.getLastINode().getId()) {
+          // src is ez root and dest is not in an ez. Allow the rename.
+          return;
+        }
         throw new IOException(
             src + " can't be moved from an encryption zone.");
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18d38cdd/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
index 34481cc..f43f460 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
@@ -576,6 +576,19 @@ public class TestEncryptionZones {
         !wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar));
     assertEquals("Renamed file contents not the same",
         contents, DFSTestUtil.readFile(fs, pathFooBarFile));
+
+    // Verify that we can rename an EZ root
+    final Path newFoo = new Path(testRoot, "newfoo");
+    assertTrue("Rename of EZ root", fs.rename(pathFoo, newFoo));
+    assertTrue("Rename of EZ root failed",
+        !wrapper.exists(pathFoo) && wrapper.exists(newFoo));
+
+    // Verify that we can't rename an EZ root onto itself
+    try {
+      wrapper.rename(newFoo, newFoo);
+    } catch (IOException e) {
+      assertExceptionContains("are the same", e);
+    }
   }
 
   @Test(timeout = 60000)

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18d38cdd/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml
index ebbf773..89c93e2 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml
@@ -238,13 +238,35 @@
     </test>
 
     <test>
-      <description>Test failure of renaming a non-EZ file from an EZ</description>
+        <description>Test failure of renaming an EZ file into a non-EZ</description>
+        <test-commands>
+            <command>-fs NAMENODE -mkdir /src</command>
+            <command>-fs NAMENODE -mkdir /dst</command>
+            <command>-fs NAMENODE -ls /</command>-
+            <crypto-admin-command>-createZone -path /src -keyName myKey</crypto-admin-command>
+            <command>-fs NAMENODE -touchz /src/foo</command>
+            <command>-fs NAMENODE -mv /src/foo /dst</command>-
+        </test-commands>
+        <cleanup-commands>
+            <command>-fs NAMENODE -rm /src/foo</command>
+            <command>-fs NAMENODE -rmdir /src</command>
+            <command>-fs NAMENODE -rmdir /dst</command>
+        </cleanup-commands>
+        <comparators>
+            <comparator>
+                <type>SubstringComparator</type>
+                <expected-output>/src/foo can't be moved from an encryption zone.</expected-output>
+            </comparator>
+        </comparators>
+    </test>
+
+    <test>
+      <description>Test success of renaming an EZ root</description>
       <test-commands>
         <command>-fs NAMENODE -mkdir /src</command>
-        <command>-fs NAMENODE -mkdir /dst</command>
-        <command>-fs NAMENODE -ls /</command>-
         <crypto-admin-command>-createZone -path /src -keyName myKey</crypto-admin-command>
         <command>-fs NAMENODE -mv /src /dst</command>-
+        <command>-fs NAMENODE -ls /</command>-
       </test-commands>
       <cleanup-commands>
         <command>-fs NAMENODE -rmdir /src</command>
@@ -253,7 +275,7 @@
       <comparators>
         <comparator>
           <type>SubstringComparator</type>
-          <expected-output>/src can't be moved from an encryption zone</expected-output>
+          <expected-output>/dst</expected-output>
         </comparator>
       </comparators>
     </test>


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


Mime
View raw message