devmadhuu commented on code in PR #6969:
URL: https://github.com/apache/ozone/pull/6969#discussion_r1802968266
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -477,17 +428,90 @@ public Response getDeletedKeySummary() {
@GET
@Path("/deletePending")
public Response getDeletedKeyInfo(
- @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
- int limit,
- @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY)
- String prevKey) {
- KeyInsightInfoResponse
- deletedKeyInsightInfo = new KeyInsightInfoResponse();
- getPendingForDeletionKeyInfo(limit, prevKey,
- deletedKeyInsightInfo);
+ @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int
limit,
+ @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY) String
prevKey,
+ @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_START_PREFIX)
String startPrefix) {
+
+ // Initialize the response object to hold the key information
+ KeyInsightInfoResponse deletedKeyInsightInfo = new
KeyInsightInfoResponse();
+
+ boolean keysFound = false;
+
+ try {
+ // Validate startPrefix if it's provided
+ if (isNotBlank(startPrefix) && !validateStartPrefix(startPrefix)) {
+ return createBadRequestResponse("Invalid startPrefix: Path must be at
the bucket level or deeper.");
+ }
+
+ // Perform the search based on the limit, prevKey, and startPrefix
+ keysFound = getPendingForDeletionKeyInfo(limit, prevKey, startPrefix,
deletedKeyInsightInfo);
+
+ } catch (IllegalArgumentException e) {
+ LOG.debug("Invalid startPrefix provided: {}", startPrefix, e);
+ return createBadRequestResponse("Invalid startPrefix: " +
e.getMessage());
+ } catch (IOException e) {
+ LOG.debug("I/O error while searching deleted keys in OM DB", e);
Review Comment:
Since we are wrapping only `e.getMessage` in returned response, so exact
issue may be difficult to know in case of real time cluster when we have used
`LOG.debug`. Is it not better to use `LOG.error` because once some issue occurs
in real time cluster, we again try to repro by enabling debug level. Same
comment for other catch blocks.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightSearchEndpoint.java:
##########
@@ -389,4 +346,20 @@ private KeyEntityInfo
createKeyEntityInfoFromOmKeyInfo(String dbKey,
return keyEntityInfo;
}
+ private boolean validateStartPrefix(String startPrefix) {
Review Comment:
This similar method is duplicated in `OMDBInsightEndpoint` class also. Given
this comment earlier but not fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]