From 120356d879a89037f16f564428a2f0be2f8d1bf5 Mon Sep 17 00:00:00 2001 From: Priya Sharma Date: Wed, 8 Jul 2026 10:51:32 +0530 Subject: [PATCH] fix: correctly identify alluxio root mount path in multi-mount datasets Signed-off-by: Priya Sharma --- pkg/utils/ufs_path_builder.go | 10 +++++----- pkg/utils/ufs_path_builder_test.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkg/utils/ufs_path_builder.go b/pkg/utils/ufs_path_builder.go index 35a58d4a5fe..f8fe401f9e2 100644 --- a/pkg/utils/ufs_path_builder.go +++ b/pkg/utils/ufs_path_builder.go @@ -47,18 +47,18 @@ func (u UFSPathBuilder) GenUFSPathInUnifiedNamespace(mount datav1alpha1.Mount) s // GenAlluxioUFSRootPath determines which mount point should be mounted on the root path of // the [unified namespace] in Alluxio engine. Commonly there are two cases: // -// 1. If a `mount` item is the only item defined in `dataset.sepc.mounts[*]` and its ufs path equals to "/", its `mountpoint` should be on the root path. +// 1. If any `mount` item defined in `dataset.spec.mounts[*]` has its ufs path equal to "/", its `mountpoint` should be on the root path. // e.g. alluxio fs mount s3://mybucket / // 2. Otherwise, pick `/underFSStorage` as the default root path. // e.g. alluxio fs mount /underFSStorage / && alluxio fs mount s3://mybucket /mybucket // // [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) { - if len(items) == 1 { - m := items[0] + 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 } } diff --git a/pkg/utils/ufs_path_builder_test.go b/pkg/utils/ufs_path_builder_test.go index 3db2c0006c1..3e02fee0342 100644 --- a/pkg/utils/ufs_path_builder_test.go +++ b/pkg/utils/ufs_path_builder_test.go @@ -28,6 +28,22 @@ func TestGenUFSRootPathForAlluxio(t *testing.T) { wantMount *datav1alpha1.Mount wantRootPath string }{ + "test multi mount item with root path": { + mounts: append( + mockMountSingleItem("spark", "https://mirrors.bit.edu.cn/apache/spark/", ""), + datav1alpha1.Mount{ + Name: "flink", + MountPoint: "https://mirrors.bit.edu.cn/apache/flink/", + Path: "/", + }, + ), + wantRootPath: "https://mirrors.bit.edu.cn/apache/flink/", + wantMount: &datav1alpha1.Mount{ + Name: "flink", + MountPoint: "https://mirrors.bit.edu.cn/apache/flink/", + Path: "/", + }, + }, "test multi mount item case 1": { mounts: mockMountMultiItems(mockMountSingleItem("spark", "local://mnt/local/path", "")), wantRootPath: "/underFSStorage",