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: allow users to override juicefs attr-cache and entry-cache options #4194

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
2 changes: 1 addition & 1 deletion pkg/ddc/efc/create_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (e *EFCEngine) createPersistentVolumeForRuntime(runtime base.RuntimeInfoInt
if err != nil {
return err
}

storageCapacity, err := utils.GetPVCStorageCapacityOfDataset(e.Client, runtime.GetName(), runtime.GetNamespace())
if err != nil {
return err
Expand Down
37 changes: 18 additions & 19 deletions pkg/ddc/juicefs/transform_fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
"github.com/fluid-cloudnative/fluid/pkg/utils/security"
)

func setDefaultOptions(options map[string]string, key string, defaultValue string) {
utils.SetValueIfKeyAbsent(options, key, defaultValue)
}

func (j *JuiceFSEngine) transformFuse(runtime *datav1alpha1.JuiceFSRuntime, dataset *datav1alpha1.Dataset, value *JuiceFS) (err error) {
if len(dataset.Spec.Mounts) <= 0 {
return errors.New("do not assign mount point")
Expand Down Expand Up @@ -345,18 +349,17 @@ func (j *JuiceFSEngine) genFuseMount(value *JuiceFS, optionMap map[string]string
}
if value.Edition == CommunityEdition {
if readonly {
optionMap["attr-cache"] = "7200"
optionMap["entry-cache"] = "7200"
setDefaultOptions(optionMap, "attr-cache", "7200")
setDefaultOptions(optionMap, "entry-cache", "7200")
}

// set metrics port
if _, ok := optionMap["metrics"]; !ok {
metricsPort := DefaultMetricsPort
if value.Fuse.MetricsPort != nil {
metricsPort = *value.Fuse.MetricsPort
}
optionMap["metrics"] = fmt.Sprintf("0.0.0.0:%d", metricsPort)
metricsPort := DefaultMetricsPort
if value.Fuse.MetricsPort != nil {
metricsPort = *value.Fuse.MetricsPort
}
setDefaultOptions(optionMap, "metrics", fmt.Sprintf("0.0.0.0:%d", metricsPort))

mountArgs = []string{
common.JuiceFSCeMountPath,
value.Source,
Expand All @@ -366,21 +369,17 @@ func (j *JuiceFSEngine) genFuseMount(value *JuiceFS, optionMap map[string]string
}
} else {
if readonly {
optionMap["attrcacheto"] = "7200"
optionMap["entrycacheto"] = "7200"
setDefaultOptions(optionMap, "attrcacheto", "7200")
setDefaultOptions(optionMap, "entrycacheto", "7200")
}
// Avoid setDefaultOptions because foreground and no-update are REQUIRED options.
optionMap["foreground"] = ""
// do not update config again
optionMap["no-update"] = ""
optionMap["no-update"] = "" // do not update config again

// start independent cache cluster, refer to [juicefs cache sharing](https://juicefs.com/docs/cloud/cache/#client_cache_sharing)
// start independent cache cluster, refer to [juicefs distributed cache](https://juicefs.com/docs/cloud/guide/distributed-cache#architecture)
// fuse and worker use the same cache-group, fuse use no-sharing
cacheGroup := fmt.Sprintf("%s-%s", j.namespace, value.FullnameOverride)
if _, ok := optionMap["cache-group"]; ok {
cacheGroup = optionMap["cache-group"]
}
optionMap["cache-group"] = cacheGroup
optionMap["no-sharing"] = ""
setDefaultOptions(optionMap, "cache-group", fmt.Sprintf("%s-%s", j.namespace, value.FullnameOverride))
setDefaultOptions(optionMap, "no-sharing", "")

mountArgs = []string{
common.JuiceFSMountPath,
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func FuseSidecarUnprivileged(infos map[string]string) (match bool) {
}

// FuseSidecarPrivileged decides if the injected fuse sidecar should be privileged, only used when fuse sidecar should be injected
// - sidecar is privileged only when setting serverless.fluid.io/inject=true without unprivileged.sidecar.fluid.io/inject=true
// - sidecar is privileged only when setting serverless.fluid.io/inject=true without unprivileged.sidecar.fluid.io/inject=true
func FuseSidecarPrivileged(infos map[string]string) (match bool) {
return enabled(infos, common.InjectServerless) && !(enabled(infos, common.InjectUnprivilegedFuseSidecar))
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ func IntersectIntegerSets(map1 map[int]bool, map2 map[int]bool) map[int]bool {

return ret
}

// SetValueIfKeyAbsent sets value when key is not found in the map.
func SetValueIfKeyAbsent(m map[string]string, key string, value string) {
if _, found := m[key]; !found {
m[key] = value
}
}
Loading