From 2723eedbc5542a811dce3f24fba18eedb2c55f84 Mon Sep 17 00:00:00 2001 From: xliuqq Date: Thu, 18 Jan 2024 16:58:30 +0800 Subject: [PATCH] pass AccessModes to thinruntime fuse container (#3696) * pass AccessModes to thinruntime fuse container Signed-off-by: xliuqq * default read only many Signed-off-by: xliuqq --------- Signed-off-by: xliuqq --- pkg/ddc/thin/transform_config.go | 5 +++++ pkg/ddc/thin/transform_fuse_test.go | 5 +++-- pkg/ddc/thin/type.go | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/ddc/thin/transform_config.go b/pkg/ddc/thin/transform_config.go index 98832ff7213..16694528e8e 100644 --- a/pkg/ddc/thin/transform_config.go +++ b/pkg/ddc/thin/transform_config.go @@ -76,6 +76,11 @@ func (t *ThinEngine) transformFuseConfig(runtime *datav1alpha1.ThinRuntime, data config.TargetPath = t.getTargetPath() config.PersistentVolumeAttrs = pvAttributes config.PersistentVolumeMountOptions = pvMountOptions + config.AccessModes = dataset.Spec.AccessModes + + if len(config.AccessModes) == 0 { + config.AccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadOnlyMany} + } var configStr []byte configStr, err = json.Marshal(config) diff --git a/pkg/ddc/thin/transform_fuse_test.go b/pkg/ddc/thin/transform_fuse_test.go index 2e362968ecc..6ee73e08cc3 100644 --- a/pkg/ddc/thin/transform_fuse_test.go +++ b/pkg/ddc/thin/transform_fuse_test.go @@ -394,6 +394,7 @@ func TestThinEngine_transformFuse(t1 *testing.T) { SharedOptions: map[string]string{ "c": "d", }, + AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany}, Mounts: []datav1alpha1.Mount{{ MountPoint: "abc", Options: map[string]string{"a": "b"}, @@ -486,7 +487,7 @@ func TestThinEngine_transformFuse(t1 *testing.T) { }}, // ConfigValue: "{\"/thin/fluid/test/thin-fuse\":\"a=b\"}", // MountPath: "/thin/fluid/test/thin-fuse", - ConfigValue: "{\"mounts\":[{\"mountPoint\":\"abc\",\"options\":{\"a\":\"b\",\"c\":\"d\"}}],\"targetPath\":\"/thin/fluid/test/thin-fuse\",\"runtimeOptions\":{\"fuse-opt\":\"foo\"}}", + ConfigValue: "{\"mounts\":[{\"mountPoint\":\"abc\",\"options\":{\"a\":\"b\",\"c\":\"d\"}}],\"targetPath\":\"/thin/fluid/test/thin-fuse\",\"runtimeOptions\":{\"fuse-opt\":\"foo\"},\"accessModes\":[\"ReadWriteMany\"]}", ConfigStorage: "configmap", }, } @@ -705,7 +706,7 @@ func TestThinEngine_transformFuseWithDuplicateOptionKey(t1 *testing.T) { }}, // ConfigValue: "{\"/thin/fluid/test/thin-fuse\":\"a=b\"}", // MountPath: "/thin/fluid/test/thin-fuse", - ConfigValue: "{\"mounts\":[{\"mountPoint\":\"abc\",\"options\":{\"a\":\"b\"}}],\"targetPath\":\"/thin/fluid/test/thin-fuse\"}", + ConfigValue: "{\"mounts\":[{\"mountPoint\":\"abc\",\"options\":{\"a\":\"b\"}}],\"targetPath\":\"/thin/fluid/test/thin-fuse\",\"accessModes\":[\"ReadOnlyMany\"]}", ConfigStorage: "configmap", }, } diff --git a/pkg/ddc/thin/type.go b/pkg/ddc/thin/type.go index 913b805398f..c7ffd1f784f 100644 --- a/pkg/ddc/thin/type.go +++ b/pkg/ddc/thin/type.go @@ -83,6 +83,7 @@ type Config struct { RuntimeOptions map[string]string `json:"runtimeOptions,omitempty"` PersistentVolumeAttrs map[string]*corev1.CSIPersistentVolumeSource `json:"persistentVolumeAttrs,omitempty"` PersistentVolumeMountOptions map[string][]string `json:"persistentVolumeMountOptions,omitempty"` + AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"` } // RuntimeSetConfig is with the info of the workers and fuses