Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut
// redundant tombstone entry in the deletedTable. It is better to skip the transaction.
UUID expectedPreviousSnapshotId = purgeKeysRequest.getExpectedPreviousSnapshotID().hasUuid()
? fromProtobuf(purgeKeysRequest.getExpectedPreviousSnapshotID().getUuid()) : null;
validatePreviousSnapshotId(fromSnapshotInfo, omMetadataManager.getSnapshotChainManager(),
expectedPreviousSnapshotId);
if (!validatePreviousSnapshotId(fromSnapshotInfo, omMetadataManager.getSnapshotChainManager(),
expectedPreviousSnapshotId)) {
return new OMKeyPurgeResponse(createErrorOMResponse(omResponse,
new OMException("Snapshot validation failed", OMException.ResultCodes.INVALID_REQUEST)));
}
}
} catch (IOException e) {
LOG.error("Error occurred while performing OmKeyPurge. ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,17 @@ public static UUID getLatestPathSnapshotId(String volumeName, String bucketName,
return snapshotChainManager.getLatestPathSnapshotId(snapshotPath);
}

// Validates the previous path snapshotId for given a snapshotInfo. In case snapshotInfo is
// null, the snapshotInfo would be considered as AOS and previous snapshot becomes the latest snapshot in the global
// snapshot chain. Would throw OMException if validation fails otherwise function would pass.
public static void validatePreviousSnapshotId(SnapshotInfo snapshotInfo,
public static boolean validatePreviousSnapshotId(SnapshotInfo snapshotInfo,
SnapshotChainManager snapshotChainManager,
UUID expectedPreviousSnapshotId) throws IOException {
UUID previousSnapshotId = snapshotInfo == null ? snapshotChainManager.getLatestGlobalSnapshotId() :
SnapshotUtils.getPreviousSnapshotId(snapshotInfo, snapshotChainManager);
if (!Objects.equals(expectedPreviousSnapshotId, previousSnapshotId)) {
throw new OMException("Snapshot validation failed. Expected previous snapshotId : " +
expectedPreviousSnapshotId + " but was " + previousSnapshotId,
OMException.ResultCodes.INVALID_REQUEST);
LOG.warn("Snapshot validation failed. Expected previous snapshotId : " +
expectedPreviousSnapshotId + " but was " + previousSnapshotId);
return false;
}
return true;
}

/**
Expand Down