Skip to content

HDDS-15624. Resolve link bucket properties in listBucket.#10745

Merged
SaketaChalamchala merged 4 commits into
apache:masterfrom
SaketaChalamchala:HDDS-15624-2
Jul 23, 2026
Merged

HDDS-15624. Resolve link bucket properties in listBucket.#10745
SaketaChalamchala merged 4 commits into
apache:masterfrom
SaketaChalamchala:HDDS-15624-2

Conversation

@SaketaChalamchala

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Link buckets created with ozone sh bucket link store link metadata (sourceVolume, sourceBucket) plus placeholder operational fields (layout, replication, quotas, etc.). getBucketInfo already resolved source properties server-side (since HDDS-9117), but listBuckets returned raw DB rows. UIs and clients that use operational fields off of the list buckets response show incorrect layout/replication for links (e.g. cluster default FSO instead of source OBS).

This change applies the same server-side link resolution to listBuckets by extracting shared enrichment logic used by both getBucketInfo and listBuckets.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15624

How was this patch tested?

Unit Tests.

(cherry picked from commit 228f523de68218907d4658aae0df59a1321a6f35)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect operational properties returned for link buckets in listBuckets by applying the same server-side link resolution/enrichment that already exists for getBucketInfo. This prevents clients/UIs from misreporting layout/replication for linked buckets (eg showing cluster defaults instead of the source bucket’s properties).

Changes:

  • Enrich listBuckets results by resolving link buckets and overlaying the source bucket’s operational properties.
  • Extract the link-bucket enrichment logic into a shared helper used by both getBucketInfo and listBuckets.
  • Add a unit test covering listBuckets link resolution for both FSO and OBS bucket layouts (and their replication configs).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java Enriches listBuckets responses for link buckets by resolving links and overlaying source bucket operational properties (also reused by getBucketInfo).
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestBucketManagerImpl.java Adds a unit test ensuring listBuckets returns resolved layout/replication for both FSO and OBS link buckets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2998 to +3002
List<OmBucketInfo> enrichedBuckets = new ArrayList<>(buckets.size());
for (OmBucketInfo bucket : buckets) {
enrichedBuckets.add(enrichLinkBucketInfo(bucket));
}
return enrichedBuckets;
}
metrics.incNumBucketLists();
return bucketManager.listBuckets(volumeName,
List<OmBucketInfo> buckets = bucketManager.listBuckets(volumeName,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like that the list buckets is a short lived object. it would be nice if we can reuse this list object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the commit to reuse the list.

Comment on lines +3040 to +3058
OmBucketInfo realBucket =
bucketManager.getBucketInfo(
resolvedBucket.realVolume(),
resolvedBucket.realBucket());
// Pass the real bucket metadata in the link bucket info.
return bucketInfo.toBuilder()
.setDefaultReplicationConfig(
realBucket.getDefaultReplicationConfig())
.setIsVersionEnabled(realBucket.getIsVersionEnabled())
.setStorageType(realBucket.getStorageType())
.setQuotaInBytes(realBucket.getQuotaInBytes())
.setQuotaInNamespace(realBucket.getQuotaInNamespace())
.setUsedBytes(realBucket.getUsedBytes())
.setSnapshotUsedBytes(realBucket.getSnapshotUsedBytes())
.setSnapshotUsedNamespace(realBucket.getSnapshotUsedNamespace())
.setUsedNamespace(realBucket.getUsedNamespace())
.addAllMetadata(realBucket.getMetadata())
.setBucketLayout(realBucket.getBucketLayout())
.build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is going to be hard to maintain in the future, if we add additional fields to the bucket.

What if we instantiate a bucketInfo object from realBucket, and update volumeName, bucketName instead.

@jojochuang jojochuang Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH i'm not sure that's a good suggestion or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the bucketInfo builder from the source closer to where the properties are added in OmBucketInfo.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@jojochuang jojochuang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i think this is good. will merge with the debug message suggestion from Copilot.

* <p>When adding new operational bucket fields, update this method if they
* should be resolved from a link's source bucket.
*/
public OmBucketInfo withOperationalPropertiesFrom(OmBucketInfo source) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@jojochuang
jojochuang marked this pull request as ready for review July 22, 2026 02:18
Copilot AI review requested due to automatic review settings July 22, 2026 02:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines +416 to +421
.setSnapshotUsedBytes(source.getSnapshotUsedBytes())
.setSnapshotUsedNamespace(source.getSnapshotUsedNamespace())
.addAllMetadata(source.getMetadata())
.setBucketLayout(source.getBucketLayout())
.setTags(source.getTags())
.build();
Comment on lines +3002 to +3004
} catch (IOException e) {
LOG.debug("Failed to enrich listBuckets entry for {}/{}; returning raw entry", volumeName, buckets.get(i).getBucketName(), e);
}
…uckets

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: Ic58109e086074097ef3d5c9395174ffacd41caa0
@SaketaChalamchala
SaketaChalamchala merged commit 77ceb29 into apache:master Jul 23, 2026
45 checks passed
@smengcl

smengcl commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@SaketaChalamchala I found two related issues with this (missing ACL check, didn't copy EncryptionKeyInfo).

Filed HDDS-15961 for them. PTAL. PR: #10859

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants