Skip to content

fix: correctly identify alluxio root mount path in multi-mount datasets#6103

Open
Priya-Sharma25 wants to merge 1 commit into
fluid-cloudnative:masterfrom
Priya-Sharma25:fix/issue-3379-multi-mount-root
Open

fix: correctly identify alluxio root mount path in multi-mount datasets#6103
Priya-Sharma25 wants to merge 1 commit into
fluid-cloudnative:masterfrom
Priya-Sharma25:fix/issue-3379-multi-mount-root

Conversation

@Priya-Sharma25

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

This PR fixes a bug where AlluxioRuntime fails to correctly mount the root path (/) if multiple mount points are defined in the dataset. Previously, GenAlluxioUFSRootPath only checked for the root path if len(items) == 1, defaulting to /underFSStorage for 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 path to TestGenUFSRootPathForAlluxio in pkg/utils/ufs_path_builder_test.go to 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

@fluid-e2e-bot

fluid-e2e-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zwwhdls for approval by writing /assign @zwwhdls in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot

fluid-e2e-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment thread pkg/utils/ufs_path_builder.go Outdated
Comment on lines 57 to 61
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
}

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.

medium

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
		}

@Priya-Sharma25

Priya-Sharma25 commented Jul 8, 2026

Copy link
Copy Markdown
Author

Could you please take a look when you have a chance?
I've also updated the code based on the suggestions from gemini-code-assist.

@cheyang @TrafalgarZZZ @xliuqq

Thanks!

@Priya-Sharma25 Priya-Sharma25 force-pushed the fix/issue-3379-multi-mount-root branch 2 times, most recently from cabf68f to 5d568f5 Compare July 8, 2026 05:30
@cheyang

cheyang commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

/copilot review

@cheyang

cheyang commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@gemini-code-assist /review

@gemini-code-assist gemini-code-assist Bot 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.

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) {

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.

medium

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.

@cheyang

cheyang commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Clean bug fix. The logic change is correct: iterating all mounts to find the root-path candidate instead of gating on len(items) == 1 fixes the reported issue for multi-mount datasets. Pointer handling (&items[i]) is sound and the new test case covers the key regression scenario. Only nit: the GoDoc on line 52 still describes the old single-item restriction and should be updated to match the new behavior.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.76%. Comparing base (afca615) to head (120356d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Priya Sharma <priyasharma1001a@gmail.com>
@Priya-Sharma25 Priya-Sharma25 force-pushed the fix/issue-3379-multi-mount-root branch from 5d568f5 to 120356d Compare July 8, 2026 07:18
@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@Priya-Sharma25

Copy link
Copy Markdown
Author

@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.

@cheyang

cheyang commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

/copilot review

@cheyang

cheyang commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@gemini-code-assist /review

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment on lines +57 to 63
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
}
}

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.

medium

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.

Suggested change
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
}
}

@Priya-Sharma25

Copy link
Copy Markdown
Author

@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!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][AlluxioRuntime] multiple mountPoint containing root path is not correct mounted in alluxio

2 participants