fix: correctly identify alluxio root mount path in multi-mount datasets#6103
fix: correctly identify alluxio root mount path in multi-mount datasets#6103Priya-Sharma25 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Priya-Sharma25. Thanks for your PR. I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Code Review
This pull request updates GenAlluxioUFSRootPath to iterate through all mount items to find the root path in the cache UFS, rather than only checking when there is a single item, and adds a corresponding test case. A review comment correctly points out that taking the address of the loop variable m (&m) returns a pointer to a local copy of the slice element, which can lead to bugs or inefficiencies. The reviewer suggests iterating by index to safely reference the actual slice element.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for _, m := range items { | ||
| // iff m matches all of the two following conditions (1) m is not a fluid-native mount point; (2) m.Path is "/", it should be the root path in cache UFS. | ||
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(m) == common.RootDirPath { | ||
| return m.MountPoint, &m | ||
| } |
There was a problem hiding this comment.
Taking the address of the loop variable m (&m) returns a pointer to a local copy of the slice element rather than the actual element in the slice. If the caller modifies the returned mount, those changes will be lost. Additionally, copying the entire datav1alpha1.Mount struct on every iteration is inefficient.
To fix this, iterate by index and use a pointer to the slice element.
for i := range items {
m := &items[i]
// iff m matches all of the two following conditions (1) m is not a fluid-native mount point; (2) m.Path is "/", it should be the root path in cache UFS.
if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(*m) == common.RootDirPath {
return m.MountPoint, m
}|
Could you please take a look when you have a chance? @cheyang @TrafalgarZZZ @xliuqq Thanks! |
cabf68f to
5d568f5
Compare
|
/copilot review |
|
@gemini-code-assist /review |
There was a problem hiding this comment.
Code Review
This pull request updates GenAlluxioUFSRootPath to support identifying the root path in multi-mount scenarios instead of restricting it to single-mount configurations, and adds a corresponding unit test. The feedback suggests updating the function's documentation comment, which is now outdated as it still references the single-mount restriction.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| @@ -54,11 +54,11 @@ func (u UFSPathBuilder) GenUFSPathInUnifiedNamespace(mount datav1alpha1.Mount) s | |||
| // | |||
| // [unified namespace]: https://docs.alluxio.io/os/user/stable/en/core-services/Unified-Namespace.html | |||
| func (u UFSPathBuilder) GenAlluxioUFSRootPath(items []datav1alpha1.Mount) (string, *datav1alpha1.Mount) { | |||
There was a problem hiding this comment.
The documentation comment for GenAlluxioUFSRootPath (lines 50-53) is now outdated. It still states that the root path is only used if there is only a single mount item defined in dataset.spec.mounts. Since this PR enables identifying the root path in multi-mount scenarios, please update the documentation comment to reflect this new behavior.
|
Clean bug fix. The logic change is correct: iterating all mounts to find the root-path candidate instead of gating on |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6103 +/- ##
=======================================
Coverage 64.76% 64.76%
=======================================
Files 485 485
Lines 33895 33895
=======================================
Hits 21952 21952
Misses 10220 10220
Partials 1723 1723 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Priya Sharma <priyasharma1001a@gmail.com>
5d568f5 to
120356d
Compare
|
|
@cheyang , Thanks for the review and catching that! I've updated the GoDoc comment for GenAlluxioUFSRootPath to properly describe the new multi-mount behavior instead of the old single-item restriction. |
|
/copilot review |
|
@gemini-code-assist /review |
There was a problem hiding this comment.
Code Review
This pull request updates GenAlluxioUFSRootPath to iterate through all mount items to find the root path, rather than restricting the check to when only a single mount item exists. A corresponding unit test was also added. The review feedback highlights a potential issue where returning a pointer directly to a slice element (&items[i]) could lead to accidental mutations of the original slice; it is recommended to copy the element by value first and return a pointer to the copy.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for i := range items { | ||
| m := &items[i] | ||
| // only iff m matches all of the two following conditions (1) m is not a fluid-native mount point; (2) m.Path is "/", it should be the root path in cache UFS. | ||
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(m) == common.RootDirPath { | ||
| return m.MountPoint, &m | ||
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(*m) == common.RootDirPath { | ||
| return m.MountPoint, m | ||
| } | ||
| } |
There was a problem hiding this comment.
Returning a pointer directly to the slice element (&items[i]) can lead to accidental mutations of the original slice elements (which typically belong to dataset.Spec.Mounts in Kubernetes controllers). This breaks the read-only assumption of the spec and can cause subtle bugs or unexpected reconciliations.
To prevent this, copy the slice element by value first, and then return a pointer to the copy (which will be safely allocated on the heap by Go's escape analysis). This also simplifies the code by avoiding the need to dereference *m when calling GenUFSPathInUnifiedNamespace.
| for i := range items { | |
| m := &items[i] | |
| // only iff m matches all of the two following conditions (1) m is not a fluid-native mount point; (2) m.Path is "/", it should be the root path in cache UFS. | |
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(m) == common.RootDirPath { | |
| return m.MountPoint, &m | |
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(*m) == common.RootDirPath { | |
| return m.MountPoint, m | |
| } | |
| } | |
| for i := range items { | |
| m := items[i] | |
| // only iff m matches all of the two following conditions (1) m is not a fluid-native mount point; (2) m.Path is "/", it should be the root path in cache UFS. | |
| if !common.IsFluidNativeScheme(m.MountPoint) && u.GenUFSPathInUnifiedNamespace(m) == common.RootDirPath { | |
| return m.MountPoint, &m | |
| } | |
| } |
|
@cheyang , I've addressed your GoDoc comment. The gemini-code-assist bot is suggesting a copy-based pointer return, but since the original code already used &items[0] with the same pattern and you confirmed the pointer handling is sound, I believe this is ready. Please let me know if any further changes are needed! |



Ⅰ. Describe what this PR does
This PR fixes a bug where
AlluxioRuntimefails to correctly mount the root path (/) if multiple mount points are defined in the dataset. Previously,GenAlluxioUFSRootPathonly checked for the root path iflen(items) == 1, defaulting to/underFSStoragefor multi-mount scenarios. This changes the logic to iterate through all mount items to accurately identify the root path.Ⅱ. Does this pull request fix one issue?
fixes #3379
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Added
test multi mount item with root pathtoTestGenUFSRootPathForAlluxioinpkg/utils/ufs_path_builder_test.goto ensure root paths are successfully identified in multi-mount scenarios.Ⅳ. Describe how to verify it
Run unit tests for
ufs_path_builder_test.go:go test ./pkg/utils/ -run "TestGenUFSRootPathForAlluxio" -vⅤ. Special notes for reviews
NONE