HDFS-13292. Crypto command should give proper exception when trying to set key on existing EZ directory. Contributed by Ranith Sardar.
This commit is contained in:
parent
00ebec89f1
commit
70590cd8d9
|
@ -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
|
||||
|
|
|
@ -113,6 +113,25 @@
|
|||
</comparators>
|
||||
</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>
|
||||
|
|
Loading…
Reference in New Issue