HDFS-13292. Crypto command should give proper exception when trying to set key on existing EZ directory. Contributed by Ranith Sardar.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/70590cd8 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/70590cd8 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/70590cd8 Branch: refs/heads/HDFS-7240 Commit: 70590cd8d948de581e2ae1184afb08574c67bbbe Parents: 00ebec8 Author: Surendra Singh Lilhore <surendralilh...@apache.org> Authored: Sat Apr 7 11:23:49 2018 +0530 Committer: Surendra Singh Lilhore <surendralilh...@apache.org> Committed: Sat Apr 7 11:23:49 2018 +0530 ---------------------------------------------------------------------- .../server/namenode/EncryptionZoneManager.java | 8 ++++---- .../src/test/resources/testCryptoConf.xml | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/70590cd8/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 b1bca98..d06cd1c 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 @@ -541,10 +541,6 @@ public class EncryptionZoneManager { if (srcIIP.getLastINode() == null) { throw new FileNotFoundException("cannot find " + srcIIP.getPath()); } - if (dir.isNonEmptyDirectory(srcIIP)) { - throw new IOException( - "Attempt to create an encryption zone for a non-empty directory."); - } INode srcINode = srcIIP.getLastINode(); if (!srcINode.isDirectory()) { @@ -557,6 +553,10 @@ public class EncryptionZoneManager { "Directory " + srcIIP.getPath() + " is already an encryption zone."); } + if (dir.isNonEmptyDirectory(srcIIP)) { + throw new IOException( + "Attempt to create an encryption zone for a non-empty directory."); + } final HdfsProtos.ZoneEncryptionInfoProto proto = PBHelperClient.convert(suite, version, keyName); final XAttr ezXAttr = XAttrHelper http://git-wip-us.apache.org/repos/asf/hadoop/blob/70590cd8/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 c109442..f603cc9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCryptoConf.xml @@ -114,6 +114,25 @@ </test> <test> + <description>Test failure of creating EZ on an existing EZ</description> + <test-commands> + <command>-fs NAMENODE -mkdir /foo</command> + <command>-fs NAMENODE -ls /</command>- + <crypto-admin-command>-createZone -path /foo -keyName myKey</crypto-admin-command> + <crypto-admin-command>-createZone -path /foo -keyName myKey</crypto-admin-command> + </test-commands> + <cleanup-commands> + <command>-fs NAMENODE -rmdir /foo</command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>Directory /foo is already an encryption zone</expected-output> + </comparator> + </comparators> + </test> + + <test> <description>Test success of creating an EZ as a subdir of an existing EZ.</description> <test-commands> <command>-fs NAMENODE -mkdir /foo</command> --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org