HDDS-16357. Recon fileCount API does not normalize the fileSize query parameter - #11174
Open
henry3260 wants to merge 1 commit into
Open
HDDS-16357. Recon fileCount API does not normalize the fileSize query parameter#11174henry3260 wants to merge 1 commit into
henry3260 wants to merge 1 commit into
Conversation
… parameter File counts are stored in a histogram keyed by (volume, bucket, fileSizeUpperBound). The write path normalizes the size via ReconUtils.getFileSizeUpperBound(), but UtilizationEndpoint#getFileCounts() built the lookup key from the raw fileSize query parameter, so the key only matched when the caller passed an exact bin boundary. The response also echoed the raw size instead of the bin upper bound, unlike the unfiltered branch of the same endpoint.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency in Recon’s /api/v1/utilization/fileCount endpoint where the read-path lookup used the raw fileSize query parameter instead of the histogram bin upper bound used by the write path. It aligns the endpoint behavior with how file counts are stored (and with the existing /utilization/containerCount behavior) by normalizing the query value and returning the normalized bin upper bound in the response.
Changes:
- Normalize
fileSizequery parameter viaReconUtils.getFileSizeUpperBound()before building the RocksDB lookup key. - Ensure the
fileSizefield in the filtered response reflects the bin upper bound (consistent with the unfiltered response branch). - Extend unit coverage to assert correct behavior when
fileSizeis not an exact bin boundary.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java | Normalizes fileSize to its bin upper bound for lookups and response values in getFileCounts(). |
| hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java | Adds a non-boundary fileSize query test to validate normalization and returned bin upper bound. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Recon stores file counts in a histogram keyed by
(volume, bucket, fileSizeUpperBound), where theupper bound is a power of two computed by
ReconUtils.getFileSizeUpperBound(). The write path appliesthis normalization in
FileSizeCountTaskHelper#getFileSizeCountKey(), but the read path inUtilizationEndpoint#getFileCounts()built the lookup key from the rawfileSizequery parameter.As a result,
GET /api/v1/utilization/fileCountreturned an empty list for any size that is notan exact bin boundary:
The sibling endpoint
/utilization/containerCountalready normalizes its parameter throughReconUtils.getContainerSizeUpperBound(), so the two APIs behaved inconsistently.This PR normalizes the parameter before the lookup, and sets the normalized value on the response.
The latter matters because the unfiltered branch of the same endpoint returns
key.getFileSizeUpperBound(), so without it the meaning of thefileSizeresponse field woulddepend on whether the query parameter was supplied.
Changed files:
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java-normalize
fileSizeviaReconUtils.getFileSizeUpperBound()and return the bin upper bound.hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java-add a non-boundary query assertion. The existing test only queried exact bin boundaries, which is
why this was not caught.
The write path and the on-disk layout are unchanged, so no existing Recon data is affected.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16357
How was this patch tested?
Unit tests:
mvn -pl :ozone-recon test -Dtest=TestEndpointspasses (15/15).