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 <guotongyu.gty@alibaba-inc.com>
  • Loading branch information
jiuyu committed Jan 7, 2025
1 parent 4e199c8 commit 10be1ec
Show file tree
Hide file tree
Showing 84 changed files with 410 additions and 948 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
4 changes: 2 additions & 2 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 Down Expand Up @@ -62,7 +62,7 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: vineyard-worker
fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
fluid.io/dataset: {{ .Values.fullNamespacedNameOverride }}
app.kubernetes.io/instance: {{ .Release.Namespace }}-{{ $fullName }}-worker
{{- if .Values.worker.labels }}
{{- range $key, $val := .Values.worker.labels }}
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
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
1 change: 1 addition & 0 deletions pkg/ddc/alluxio/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (e *AlluxioEngine) transform(runtime *datav1alpha1.AlluxioRuntime) (value *
}

value.FullnameOverride = e.name
value.FullNamespacedNameOverride = utils.TransferFullNamespacedNameWithPrefixToLegalValue("", e.namespace, e.name)

// 1.transform the common part
err = e.transformCommonPart(runtime, dataset, value)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/transform_fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (e *AlluxioEngine) transformFuse(runtime *datav1alpha1.AlluxioRuntime, data
} else {
value.Fuse.NodeSelector = map[string]string{}
}
value.Fuse.NodeSelector[e.getFuseLabelname()] = "true"
value.Fuse.NodeSelector[utils.GetFuseLabelName(runtime.Namespace, runtime.Name)] = "true"

// parse fuse container network mode
value.Fuse.HostNetwork = datav1alpha1.IsHostNetwork(runtime.Spec.Fuse.NetworkMode)
Expand Down
3 changes: 2 additions & 1 deletion pkg/ddc/alluxio/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (

// The value yaml file
type Alluxio struct {
FullnameOverride string `json:"fullnameOverride"`
FullnameOverride string `json:"fullnameOverride"`
FullNamespacedNameOverride string `json:"fullNamespacedNameOverride"`

common.ImageInfo `json:",inline"`
common.UserInfo `json:",inline"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/base/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func (info *RuntimeInfo) GetDatasetNumLabelName() string {

// GetFuseLabelName gets the label indicating a fuse running on some node.
func (info *RuntimeInfo) GetFuseLabelName() string {
return common.LabelAnnotationFusePrefix + info.namespace + "-" + info.name
return utils.TransferFullNamespacedNameWithPrefixToLegalValue(common.LabelAnnotationFusePrefix, info.namespace, info.name)
}
Loading

0 comments on commit 10be1ec

Please sign in to comment.