Skip to content

HDDS-14177. OFS#getTrashRoot should use the internal FS username instead of current UGI#9502

Merged
adoroszlai merged 2 commits intoapache:masterfrom
ivandika3:HDDS-14177
Dec 16, 2025
Merged

HDDS-14177. OFS#getTrashRoot should use the internal FS username instead of current UGI#9502
adoroszlai merged 2 commits intoapache:masterfrom
ivandika3:HDDS-14177

Conversation

@ivandika3
Copy link
Copy Markdown
Contributor

@ivandika3 ivandika3 commented Dec 15, 2025

What changes were proposed in this pull request?

BasicRootedOzoneFileSystem#getTrashRoot calls OFSPath#getTrashRoot which internally use UserGroupInformation#getCurrentUser. Therefore, even if FileSystem was initialized under impersonated user (e.g. proxy user), the trash root still uses the current UserGroupInformation#getCurrentUser.

We need fix getTrashRoot so that it uses the internal BasicRootedOzoneFileSystem.userName instead.

Note that BasicOzoneFileSystem#getTrashRoot (o3fs) already correctly uses the internal userName.

What is the link to the Apache JIRA

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

How was this patch tested?

Integration test. Clean run: https://github.com/ivandika3/ozone/actions/runs/20224410422

@ivandika3
Copy link
Copy Markdown
Contributor Author

Another place that might need to be fixed is getTempMountBucketNameOfCurrentUser in OFSPath#initOFSPath where it currently always use the UserGroupInformation#getCurrentUser. However, I'm not familiar with the context, so need @smengcl's opinion.

@jojochuang
Copy link
Copy Markdown
Contributor

@ivandika3 oh yeah that can break for /tmp path manipulation.

Hmm this is awkward. We would need to force OFSPath to accept a user name as a parameter, and the OFSPath usage is everywhere. I am thinking to add another OFSPath constructor to accept the "initialization user name", and abort if it turns out the path is a /tmp and that the initialization user name is not set. It's going to be awkward and error prone still.

@ivandika3
Copy link
Copy Markdown
Contributor Author

ivandika3 commented Dec 16, 2025

@jojochuang Thanks for the review. Seems creating a new constructor will create a lot of changes (+ we need to change BasicRootedOzoneClientAdapterImpl constructor to also accept username).

We might need to address this in another task after some discussions.

Copy link
Copy Markdown
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

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

Ok let's address the other API usage separately.

Currently OFSPath.getTrash() is used in TrashOzoneFileSystem which does not use impersonation or proxy user.

However IMO we should get rid of OFSPath.getTrashRoot() (no argument) otherwise it's going to be brittle if it is used elsewhere. Unless we can find another fool-proof solution.

Copy link
Copy Markdown
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @ivandika3 for the patch.

nit: we can reduce duplication by changing getTrashRoot() to:

  public Path getTrashRoot() {
    return getTrashRoot(""); // or even null
  }

@ivandika3
Copy link
Copy Markdown
Contributor Author

@adoroszlai Good point, thanks. Updated.

@adoroszlai adoroszlai merged commit 72ccb3a into apache:master Dec 16, 2025
43 checks passed
@adoroszlai
Copy link
Copy Markdown
Contributor

Thanks @ivandika3 for the patch, @jojochuang for the review.

@ivandika3 ivandika3 deleted the HDDS-14177 branch December 16, 2025 11:39
@ivandika3 ivandika3 self-assigned this Dec 16, 2025
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.

3 participants