Skip to content

Commit

Permalink
Enhancement: Unify the implementation of label concatenation across d…
Browse files Browse the repository at this point in the history
…ifferent Runtimes, and support labels with over limit length

Signed-off-by: jiuyu <[email protected]>
  • Loading branch information
jiuyu committed Jan 8, 2025
1 parent 4e199c8 commit d667065
Show file tree
Hide file tree
Showing 87 changed files with 428 additions and 955 deletions.
4 changes: 2 additions & 2 deletions charts/alluxio/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -60,7 +60,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
Expand Down
4 changes: 2 additions & 2 deletions charts/efc/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: efc-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -45,7 +45,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: efc-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
Expand Down
2 changes: 1 addition & 1 deletion charts/fluid-datamigrate/juicefs/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
role: datamigrate-pod
app: juicefs
targetDataset: {{ required "targetDataset should be set" .Values.datamigrate.targetDataset }}
fluid.io/operation: migrate-{{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/operation: migrate-{{ .Values.fullNamespacedNameOverride }}
{{- include "library.fluid.labels" . | nindent 8 }}
{{- if .Values.datamigrate.labels }}
{{- range $key, $val := .Values.datamigrate.labels }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
metadata:
labels:
app: {{ printf "%s-workers" .Release.Name }}
fluid.io/operation: migrate-{{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/operation: migrate-{{ .Values.fullNamespacedNameOverride }}
spec:
containers:
- name: worker
Expand Down
4 changes: 2 additions & 2 deletions charts/goosefs/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: goosefs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
spec:
Expand All @@ -37,7 +37,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: goosefs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
spec:
enableServiceLinks: false
Expand Down
4 changes: 2 additions & 2 deletions charts/jindocache/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -49,7 +49,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
Expand Down
4 changes: 2 additions & 2 deletions charts/jindofs/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -44,7 +44,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.labels }}
{{ toYaml .Values.labels | trim | indent 8 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/jindofsx/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -49,7 +49,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: jindofs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
Expand Down
4 changes: 2 additions & 2 deletions charts/juicefs/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: juicefs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -48,7 +48,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: juicefs-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
Expand Down
4 changes: 2 additions & 2 deletions charts/thin/templates/worker/statefuleset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: thin-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
Expand Down Expand Up @@ -41,7 +41,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: thin-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
fluid.io/dataset-placement: {{ .Values.placement }}
spec:
{{- if .Values.worker.imagePullSecrets }}
Expand Down
8 changes: 4 additions & 4 deletions charts/vineyard/templates/worker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: vineyard-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
{{- include "library.fluid.labels" . | nindent 4 }}
{{- if .Values.owner.enabled }}
ownerReferences:
Expand All @@ -46,7 +46,7 @@ spec:
chart: {{ $chart }}
release: {{ .Release.Name }}
role: vineyard-worker
app.kubernetes.io/instance: {{ .Release.Namespace }}-{{ $fullName }}-worker
app.kubernetes.io/instance: {{ .Values.fullNamespacedNameOverride }}-worker
template:
metadata:
annotations:
Expand All @@ -62,8 +62,8 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: vineyard-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Namespace }}-{{ $fullName }}-worker
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
app.kubernetes.io/instance: {{ .Values.fullNamespacedNameOverride }}-worker
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
{{ $key | quote }}: {{ $val | quote }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/runtime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (r *RuntimeReconciler) ReconcileRuntimeDeletion(engine base.Engine, ctx cru
return utils.RequeueAfterInterval(time.Duration(20 * time.Second))
}

// 1. Delete the implementation of the the runtime
// 1. Delete the implementation of the runtime
err = engine.Shutdown()
if err != nil {
r.Recorder.Eventf(ctx.Runtime, corev1.EventTypeWarning, common.ErrorProcessRuntimeReason, "Failed to shutdown engine %v", err)
Expand Down
5 changes: 2 additions & 3 deletions pkg/csi/plugins/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
// 4. remove label on node
// Once the label is removed, fuse pod on corresponding node will be terminated
// since node selector in the fuse daemonSet no longer matches.
// TODO: move all the label keys into a util func
fuseLabelKey := common.LabelAnnotationFusePrefix + namespace + "-" + name
fuseLabelKey := utils.GetFuseLabelName(namespace, name)
var labelsToModify common.LabelsToModify
labelsToModify.Delete(fuseLabelKey)

Expand Down Expand Up @@ -401,7 +400,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
}

// 4. Label node to launch FUSE Pod
fuseLabelKey := common.LabelAnnotationFusePrefix + namespace + "-" + name
fuseLabelKey := utils.GetFuseLabelName(namespace, name)
var labelsToModify common.LabelsToModify
labelsToModify.Add(fuseLabelKey, "true")

Expand Down
4 changes: 2 additions & 2 deletions pkg/ctrl/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (e *Helper) CheckFuseHealthy(recorder record.EventRecorder, runtime base.Ru
func (e *Helper) CleanUpFuse() (count int, err error) {
var (
nodeList = &corev1.NodeList{}
fuseLabelKey = common.LabelAnnotationFusePrefix + e.runtimeInfo.GetNamespace() + "-" + e.runtimeInfo.GetName()
fuseLabelKey = utils.GetFuseLabelName(e.runtimeInfo.GetNamespace(), e.runtimeInfo.GetName())
)

labelNames := []string{fuseLabelKey}
Expand Down Expand Up @@ -153,7 +153,7 @@ func (e *Helper) CleanUpFuse() (count int, err error) {
func (e *Helper) GetFuseNodes() (nodes []corev1.Node, err error) {
var (
nodeList = &corev1.NodeList{}
fuseLabelKey = common.LabelAnnotationFusePrefix + e.runtimeInfo.GetNamespace() + "-" + e.runtimeInfo.GetName()
fuseLabelKey = utils.GetFuseLabelName(e.runtimeInfo.GetNamespace(), e.runtimeInfo.GetName())
)

labelNames := []string{fuseLabelKey}
Expand Down
7 changes: 4 additions & 3 deletions pkg/datamigrate/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
)

type DataMigrateValue struct {
Name string `json:"name"`
Owner *common.OwnerReference `json:"owner,omitempty"`
DataMigrateInfo DataMigrateInfo `json:"datamigrate"`
Name string `json:"name"`
FullNamespacedNameOverride string `json:"fullNamespacedNameOverride"`
Owner *common.OwnerReference `json:"owner,omitempty"`
DataMigrateInfo DataMigrateInfo `json:"datamigrate"`
}

type DataMigrateInfo struct {
Expand Down
13 changes: 5 additions & 8 deletions pkg/ddc/alluxio/deprecated_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ limitations under the License.
package alluxio

import (
"github.com/fluid-cloudnative/fluid/pkg/common/deprecated"
"github.com/fluid-cloudnative/fluid/pkg/utils"
apierrs "k8s.io/apimachinery/pkg/api/errors"
)

func (e *AlluxioEngine) getDeprecatedCommonLabelname() string {
return deprecated.LabelAnnotationStorageCapacityPrefix + e.namespace + "-" + e.name
}

func (e *AlluxioEngine) HasDeprecatedCommonLabelname() (deprecated bool, err error) {

// return deprecated.LabelAnnotationStorageCapacityPrefix + e.namespace + "-" + e.name
Expand Down Expand Up @@ -54,11 +50,12 @@ func (e *AlluxioEngine) HasDeprecatedCommonLabelname() (deprecated bool, err err
nodeSelectors := workers.Spec.Template.Spec.NodeSelector
e.Log.Info("The current node selectors for worker", "workerName", workerName, "nodeSelector", nodeSelectors)

if _, deprecated = nodeSelectors[e.getDeprecatedCommonLabelname()]; deprecated {
deprecatedCommonLabelName := utils.GetCommonLabelName(true, e.namespace, e.name)
if _, deprecated = nodeSelectors[deprecatedCommonLabelName]; deprecated {
//
e.Log.Info("the deprecated node selector exists", "nodeSelector", e.getDeprecatedCommonLabelname())
e.Log.Info("the deprecated node selector exists", "nodeselector", deprecatedCommonLabelName)
} else {
e.Log.Info("The deprecated node selector doesn't exist", "nodeSelector", e.getDeprecatedCommonLabelname())
e.Log.Info("The deprecated node selector doesn't exist", "nodeselector", deprecatedCommonLabelName)
}

return
Expand Down
5 changes: 2 additions & 3 deletions pkg/ddc/alluxio/deprecated_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
"github.com/fluid-cloudnative/fluid/pkg/utils"
"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -65,10 +66,8 @@ func TestAlluxioEngine_GetDeprecatedCommonLabelname(t *testing.T) {
out: "data.fluid.io/storage-test-fluid",
},
}
fakeClient := fake.NewFakeClientWithScheme(testScheme)
for _, test := range testCases {
engine := getTestAlluxioEngine(fakeClient, test.name, test.namespace)
out := engine.getDeprecatedCommonLabelname()
out := utils.GetCommonLabelName(true, test.namespace, test.name)
if out != test.out {
t.Errorf("input parameter is %s-%s,expected %s, got %s", test.namespace, test.name, test.out, out)
}
Expand Down
27 changes: 0 additions & 27 deletions pkg/ddc/alluxio/label.go

This file was deleted.

53 changes: 0 additions & 53 deletions pkg/ddc/alluxio/label_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func TestSyncScheduleInfoToCacheNodes(t *testing.T) {
}

nodeList := &v1.NodeList{}
datasetLabels, err := labels.Parse(fmt.Sprintf("%s=true", engine.getCommonLabelname()))
datasetLabels, err := labels.Parse(fmt.Sprintf("%s=true", engine.runtimeInfo.GetCommonLabelName()))
if err != nil {
return
}
Expand Down
Loading

0 comments on commit d667065

Please sign in to comment.