Skip to content

Commit f8a1464

Browse files
committed
webhook cache the specific configmap and only inplace update worker pod has annotation
1 parent 1f8b4f4 commit f8a1464

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

charts/juicefs/templates/worker/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
chart: {{ template "juicefs.chart" . }}
88
release: {{ .Release.Name }}
99
heritage: {{ .Release.Service }}
10+
fluid.io/configmap-type: worker-state
1011
{{- include "library.fluid.labels" . | nindent 4 }}
1112
ownerReferences:
1213
{{- if .Values.owner.enabled }}

cmd/webhook/app/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func handle() {
138138
// restrict the number of configmap to be cached.
139139
&v1.ConfigMap{}: {
140140
Label: labels.SelectorFromSet(labels.Set{
141-
common.LabelAnnotationManagedBy: common.Fluid,
141+
common.LabelConfigMapType: common.RuntimeWorkerStateConfigMapTypeName,
142142
}),
143143
},
144144
},

pkg/common/label.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ const (
127127
RuntimePodType = "fluid.io/runtime-pod-type"
128128
RuntimeWorkerPod = "worker"
129129

130+
// LabelConfigMapType fluid.io/configmap-type is the label key for runtime configmap type
131+
LabelConfigMapType = LabelAnnotationPrefix + "configmap-type"
132+
// RuntimeWorkerStateConfigMapTypeName is the label value of the configmap type for runtime worker state
133+
RuntimeWorkerStateConfigMapTypeName = "worker-state"
134+
130135
// AnnotationRuntimeName is the annotation key for the runtime name
131136
AnnotationRuntimeName = LabelAnnotationPrefix + "runtime-name"
132137
)

pkg/ddc/juicefs/transform.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,21 @@ func (j *JuiceFSEngine) transformTolerations(dataset *datav1alpha1.Dataset, valu
261261
func (j *JuiceFSEngine) transformPodMetadata(runtime *datav1alpha1.JuiceFSRuntime, value *JuiceFS) (err error) {
262262
commonLabels := utils.UnionMapsWithOverride(map[string]string{}, runtime.Spec.PodMetadata.Labels)
263263
value.Worker.Labels = utils.UnionMapsWithOverride(commonLabels, runtime.Spec.Worker.PodMetadata.Labels)
264-
// in-place update for worker pods used in webhook mutating.
265-
value.Worker.Labels[common.RuntimePodType] = common.RuntimeWorkerPod
266-
267264
value.Fuse.Labels = utils.UnionMapsWithOverride(commonLabels, runtime.Spec.Fuse.PodMetadata.Labels)
268265

269266
commonAnnotations := utils.UnionMapsWithOverride(map[string]string{}, runtime.Spec.PodMetadata.Annotations)
270267
value.Worker.Annotations = utils.UnionMapsWithOverride(commonAnnotations, runtime.Spec.Worker.PodMetadata.Annotations)
271-
// the runtime name used in webhook mutating to mutate in-place updated worker pods.
272-
value.Worker.Annotations[common.AnnotationRuntimeName] = runtime.Name
273-
274268
value.Fuse.Annotations = utils.UnionMapsWithOverride(commonAnnotations, runtime.Spec.Fuse.PodMetadata.Annotations)
275269

270+
// only Worker Pods requiring in-place updates trigger the mutating webhook
271+
if runtime.Spec.UpdateStrategy == datav1alpha1.InPlaceIfPossible ||
272+
runtime.Spec.UpdateStrategy == datav1alpha1.InPlace {
273+
// in-place update for worker pods used in webhook mutating.
274+
value.Worker.Labels[common.RuntimePodType] = common.RuntimeWorkerPod
275+
// the runtime name used in webhook mutating to mutate in-place updated worker pods.
276+
value.Worker.Annotations[common.AnnotationRuntimeName] = runtime.Name
277+
}
278+
276279
return nil
277280
}
278281

0 commit comments

Comments
 (0)