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)); Assert.assertTrue(volumeInfo.getVolumeName().equals(volumeName2));
// Make sure volume with _A suffix is successfully deleted. // Make sure volume with _A suffix is successfully deleted.
exception.expect(IOException.class); try {
exception.expectMessage("Info Volume failed, error:VOLUME_NOT_FOUND"); volumeArgs = new VolumeArgs(volumeName1, userArgs);
volumeArgs = new VolumeArgs(volumeName1, userArgs); storageHandler.getVolumeInfo(volumeArgs);
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, // 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 // Remove the volume from the list
prevVolList.remove(volume); prevVolList.remove(volume);
if (prevVolList.size() == 0) { if (prevVolList.size() == 0) {
batch.delete(dbUserKey); batch.delete(metadataManager.getUserTable().getHandle(), dbUserKey);
} else { } else {
VolumeList newVolList = VolumeList.newBuilder() VolumeList newVolList = VolumeList.newBuilder()
.addAllVolumeNames(prevVolList).build(); .addAllVolumeNames(prevVolList).build();