HDDS-405. User/volume mapping is not cleaned up during the deletion of the last volume.

Contributed by Elek, Marton.
This commit is contained in:
Anu Engineer 2018-09-06 12:44:08 -07:00
parent eb0b5a844f
commit fa2945e7a9
2 changed files with 23 additions and 5 deletions

View File

@ -276,10 +276,28 @@ public void testDeleteVolume() throws IOException, OzoneException {
Assert.assertTrue(volumeInfo.getVolumeName().equals(volumeName2));
// Make sure volume with _A suffix is successfully deleted.
exception.expect(IOException.class);
exception.expectMessage("Info Volume failed, error:VOLUME_NOT_FOUND");
try {
volumeArgs = new VolumeArgs(volumeName1, userArgs);
storageHandler.getVolumeInfo(volumeArgs);
Assert.fail("Volume is not deleted");
} catch (IOException ex) {
Assert.assertEquals("Info Volume failed, error:VOLUME_NOT_FOUND",
ex.getMessage());
}
//delete the _AA volume, too
storageHandler.deleteVolume(new VolumeArgs(volumeName2, userArgs));
//Make sure there is no volume information for the specific user
OMMetadataManager metadataManager =
cluster.getOzoneManager().getMetadataManager();
byte[] userKey = metadataManager.getUserKey(userName);
byte[] volumes = metadataManager.getUserTable().get(userKey);
//that was the last volume of the user, shouldn't be any record here
Assert.assertNull(volumes);
}
// Create a volume and a bucket inside the volume,

View File

@ -110,7 +110,7 @@ private void delVolumeFromOwnerList(String volume, String owner,
// Remove the volume from the list
prevVolList.remove(volume);
if (prevVolList.size() == 0) {
batch.delete(dbUserKey);
batch.delete(metadataManager.getUserTable().getHandle(), dbUserKey);
} else {
VolumeList newVolList = VolumeList.newBuilder()
.addAllVolumeNames(prevVolList).build();