Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix options affecting sharedOptions in other mounts #4253

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pkg/ddc/thin/ufs_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/common"
"github.com/fluid-cloudnative/fluid/pkg/ddc/thin/operations"
"github.com/fluid-cloudnative/fluid/pkg/utils"
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
securityutil "github.com/fluid-cloudnative/fluid/pkg/utils/security"
)
Expand Down Expand Up @@ -76,13 +77,7 @@ func (t *ThinEngine) usedSpaceInternal() (usedSpace int64, err error) {
func (t *ThinEngine) genFuseMountOptions(m datav1alpha1.Mount, SharedOptions map[string]string, SharedEncryptOptions []datav1alpha1.EncryptOption, extractEncryptOptions bool) (map[string]string, error) {

// initialize mount options
mOptions := map[string]string{}
if len(SharedOptions) > 0 {
mOptions = SharedOptions
}
for key, value := range m.Options {
mOptions[key] = value
}
mOptions := utils.UnionMapsWithOverride(SharedOptions, m.Options)

// if encryptOptions have the same key with options
// it will overwrite the corresponding value
Expand Down
12 changes: 2 additions & 10 deletions pkg/utils/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,9 @@ func ContainsAll(m map[string]string, slice []string) bool {
return true
}

// UnionMapsWithOverride unions two maps into one. If either of the maps is empty, return the other one.
// If both maps share the same key, the value in map2 overrides the corresponding value in map1.
// UnionMapsWithOverride unions two maps into one. If both maps are empty or nil, return an empty map.
// If both maps share the same key, the value in map2 overrides the value in map1.
func UnionMapsWithOverride(map1 map[string]string, map2 map[string]string) map[string]string {
if len(map1) == 0 || len(map2) == 0 {
if len(map1) == 0 {
return map2
} else {
return map1
}
}

retMap := map[string]string{}
for k, v := range map1 {
retMap[k] = v
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestUnionMapsWithOverride(t *testing.T) {
map1: nil,
map2: nil,
},
want: nil,
want: map[string]string{},
},
}
for _, tt := range tests {
Expand Down
Loading