HDFS-7530. Allow renaming of encryption zone roots. Contributed by Charles Lamb.
This commit is contained in:
parent
c4d97136e0
commit
b0b9084433
|
@ -474,6 +474,8 @@ Release 2.7.0 - UNRELEASED
|
||||||
HDFS-7543. Avoid path resolution when getting FileStatus for audit logs.
|
HDFS-7543. Avoid path resolution when getting FileStatus for audit logs.
|
||||||
(wheat9)
|
(wheat9)
|
||||||
|
|
||||||
|
HDFS-7530. Allow renaming of encryption zone roots. (Charles Lamb via wang)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
||||||
|
|
|
@ -249,6 +249,10 @@ public class EncryptionZoneManager {
|
||||||
final boolean dstInEZ = (dstEZI != null);
|
final boolean dstInEZ = (dstEZI != null);
|
||||||
if (srcInEZ) {
|
if (srcInEZ) {
|
||||||
if (!dstInEZ) {
|
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(
|
throw new IOException(
|
||||||
src + " can't be moved from an encryption zone.");
|
src + " can't be moved from an encryption zone.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,6 +538,19 @@ public class TestEncryptionZones {
|
||||||
!wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar));
|
!wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar));
|
||||||
assertEquals("Renamed file contents not the same",
|
assertEquals("Renamed file contents not the same",
|
||||||
contents, DFSTestUtil.readFile(fs, pathFooBarFile));
|
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)
|
@Test(timeout = 60000)
|
||||||
|
|
|
@ -238,13 +238,35 @@
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
<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>
|
<test-commands>
|
||||||
<command>-fs NAMENODE -mkdir /src</command>
|
<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>
|
<crypto-admin-command>-createZone -path /src -keyName myKey</crypto-admin-command>
|
||||||
<command>-fs NAMENODE -mv /src /dst</command>-
|
<command>-fs NAMENODE -mv /src /dst</command>-
|
||||||
|
<command>-fs NAMENODE -ls /</command>-
|
||||||
</test-commands>
|
</test-commands>
|
||||||
<cleanup-commands>
|
<cleanup-commands>
|
||||||
<command>-fs NAMENODE -rmdir /src</command>
|
<command>-fs NAMENODE -rmdir /src</command>
|
||||||
|
@ -253,7 +275,7 @@
|
||||||
<comparators>
|
<comparators>
|
||||||
<comparator>
|
<comparator>
|
||||||
<type>SubstringComparator</type>
|
<type>SubstringComparator</type>
|
||||||
<expected-output>/src can't be moved from an encryption zone</expected-output>
|
<expected-output>/dst</expected-output>
|
||||||
</comparator>
|
</comparator>
|
||||||
</comparators>
|
</comparators>
|
||||||
</test>
|
</test>
|
||||||
|
|
Loading…
Reference in New Issue