Skip to content

Commit 2e7c3ad

Browse files
author
jiuyu
committed
Feat: support Runtime Fuse UpdateStrategy - OnIdle
Signed-off-by: 玖宇 <guotongyu.gty@alibaba-inc.com>
1 parent 441d216 commit 2e7c3ad

46 files changed

Lines changed: 1189 additions & 264 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/v1alpha1/constant.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ const (
5353
// OnRuntimeDeletedCleanPolicy cleans fuse pod only when the cache runtime is deleted
5454
OnRuntimeDeletedCleanPolicy FuseCleanPolicy = "OnRuntimeDeleted"
5555
)
56+
57+
type FuseUpdateStrategy string
58+
59+
const (
60+
// NoneFuseUpdateStrategy is the default clean policy. It will be transformed to OnDeleteFuseUpdateStrategy automatically.
61+
NoneFuseUpdateStrategy FuseUpdateStrategy = ""
62+
63+
// OnDeleteFuseUpdateStrategy cleans fuse pod once th fuse pod on some node is deleted
64+
OnDeleteFuseUpdateStrategy FuseUpdateStrategy = "OnDelete"
65+
66+
// OnIdleFuseUpdateStrategy cleans fuse pod once th fuse pod on some node is in idle
67+
OnIdleFuseUpdateStrategy FuseUpdateStrategy = "OnIdle"
68+
)

api/v1alpha1/juicefsruntime_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ type JuiceFSFuseSpec struct {
164164
// +optional
165165
CleanPolicy FuseCleanPolicy `json:"cleanPolicy,omitempty"`
166166

167+
// UpdateStrategy decides when to update Fuse pods.
168+
// Currently Fluid supports two UpdateStrategy: OnDelete and OnIdle
169+
// OnDelete update fuse pod by native daemonset once the fuse pod on some node is deleted
170+
// OnIdle update fuse pod once the fuse pod on some node is in idle
171+
// Defaults to OnDelete
172+
// +optional
173+
UpdateStrategy FuseUpdateStrategy `json:"updateStrategy,omitempty"`
174+
167175
// PodMetadata defines labels and annotations that will be propagated to JuiceFs's pods.
168176
// +optional
169177
PodMetadata PodMetadata `json:"podMetadata,omitempty"`

api/v1alpha1/openapi_generated.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/fluid/fluid/crds/data.fluid.io_juicefsruntimes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ spec:
328328
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
329329
type: object
330330
type: object
331+
updateStrategy:
332+
description: |-
333+
UpdateStrategy decides when to update Fuse pods.
334+
Currently Fluid supports two UpdateStrategy: OnDelete and OnIdle
335+
OnDelete update fuse pod by native daemonset once the fuse pod on some node is deleted
336+
OnIdle update fuse pod once the fuse pod on some node is in idle
337+
Defaults to OnDelete
338+
type: string
331339
volumeMounts:
332340
description: VolumeMounts specifies the volumes listed in ".spec.volumes"
333341
to mount into runtime component's filesystem.

charts/juicefs/templates/fuse/daemonset.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,20 @@ spec:
143143
privileged: true
144144
{{- end }}
145145
lifecycle:
146+
{{- if .Values.fuse.postStartCmd }}
147+
postStart:
148+
exec:
149+
command: ["sh", "-c", "{{ .Values.fuse.postStartCmd }}"]
150+
{{- end }}
146151
preStop:
147152
exec:
148153
command: ["sh", "-c", "umount {{ .Values.fuse.mountPath }}"]
149154
volumeMounts:
150155
- name: juicefs-fuse-mount
151156
mountPath: {{ .Values.fuse.hostMountPath }}
152157
mountPropagation: Bidirectional
158+
- name: juicefs-fuse-meta
159+
mountPath: {{ .Values.fuse.hostMetaPath }}
153160
- mountPath: /root/script
154161
name: script
155162
{{- if .Values.fuse.volumeMounts }}
@@ -161,6 +168,10 @@ spec:
161168
hostPath:
162169
path: {{ .Values.fuse.hostMountPath }}
163170
type: DirectoryOrCreate
171+
- name: juicefs-fuse-meta
172+
hostPath:
173+
path: {{ .Values.fuse.hostMetaPath }}
174+
type: DirectoryOrCreate
164175
- name: script
165176
configMap:
166177
name: {{ template "juicefs.fullname" . }}-fuse-script

charts/juicefs/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fuse:
9595
mountPath: /mnt/jfs
9696
cacheDir: ""
9797
hostMountPath: /mnt/jfs
98+
hostMetaPath: /mnt/.meta
9899
command: "/usr/local/bin/juicefs mount /mnt/jfs"
99100
statCmd: "stat -c %i /mnt/jfs"
100101
updateStrategy:

config/crd/bases/data.fluid.io_juicefsruntimes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ spec:
328328
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
329329
type: object
330330
type: object
331+
updateStrategy:
332+
description: |-
333+
UpdateStrategy decides when to update Fuse pods.
334+
Currently Fluid supports two UpdateStrategy: OnDelete and OnIdle
335+
OnDelete update fuse pod by native daemonset once the fuse pod on some node is deleted
336+
OnIdle update fuse pod once the fuse pod on some node is in idle
337+
Defaults to OnDelete
338+
type: string
331339
volumeMounts:
332340
description: VolumeMounts specifies the volumes listed in ".spec.volumes"
333341
to mount into runtime component's filesystem.

pkg/common/constants.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ const (
156156
AccelerateCategory Category = "Accelerate"
157157
)
158158

159-
var (
160-
ExpectedFluidAnnotations = map[string]string{
159+
func GetExpectedFluidAnnotations() map[string]string {
160+
return map[string]string{
161161
"CreatedBy": "fluid",
162162
}
163-
)
163+
}
164164

165165
const (
166166
FluidExclusiveKey string = "fluid_exclusive"

pkg/common/env_names.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const (
2525

2626
EnvRuntimeInfoCacheSize = "RUNTIMEINFO_CACHE_SIZE"
2727

28+
EnvRuntimeFuseImageVersion = "RUNTIMEINFO_FUSE_IMAGE_VERSION"
29+
2830
EnvEnableRuntimeInfoCache = "ENABLE_RUNTIMEINFO_CACHE"
2931

3032
EnvRuntimeInfoCacheTTL = "RUNTIMEINFO_CACHE_TTL"

pkg/common/label.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const (
8383
)
8484

8585
const (
86+
// i.e. fuse.runtime.fluid.io/image-version
87+
AnnotationRuntimeFuseImageVersion = "fuse.runtime." + LabelAnnotationPrefix + "image-version"
88+
8689
// i.e. controller.runtime.fluid.io/replicas
8790
RuntimeControllerReplicas = "controller.runtime." + LabelAnnotationPrefix + "replicas"
8891

0 commit comments

Comments
 (0)