Skip to content
Open
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
20 changes: 20 additions & 0 deletions api/v1alpha1/cacheruntimeclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ type CacheRuntimeClass struct {
// ExtraResources specifies additional resources (e.g., ConfigMaps) used by the CacheRuntime components
// +optional
ExtraResources RuntimeExtraResources `json:"extraResources,omitempty"`

// DataOperationSpecs specifies the data operation spec
// +optional
DataOperationSpecs []DataOperationSpec `json:"dataOperationSpecs,omitempty"`
}

type DataOperationSpec struct {
// Name is the data operation name like DataLoad, DataBackup, DataMigrate etc.
// +kubebuilder:validation:Enum=DataLoad;DataBackup;DataMigrate;DataProcess
Name string `json:"name"`

// Image the image for data operation, if not existed, use the runtime/runtimeclass defined worker image.
// +optional
Image string `json:"image,omitempty"`

// Command for data operation Pod container
Command []string `json:"command,omitempty"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataOperationSpec.Command has no validation — if both command and args are empty, the pod launches with the container's default entrypoint, which may produce unexpected behavior for cache engines. Should the API require at least one of command/args to be non-empty when the operation is declared?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check in genDataLoadValue.


// Args for data operation Pod container
Args []string `json:"args,omitempty"`
}

// CacheRuntimeClassList contains a list of CacheRuntimeClass
Expand Down
75 changes: 74 additions & 1 deletion api/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions charts/fluid-dataloader/cache/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v2
name: fluid-dataloader
description: A Helm chart for Fluid to prefetch data

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 0.3.0

dependencies:
- name: library
version: "0.2.0"
repository: "file://../../library"
1 change: 1 addition & 0 deletions charts/fluid-dataloader/cache/charts/library
94 changes: 94 additions & 0 deletions charts/fluid-dataloader/cache/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{{- if eq (lower .Values.dataloader.policy) "cron" }}
apiVersion: {{ ternary "batch/v1" "batch/v1beta1" (.Capabilities.APIVersions.Has "batch/v1/CronJob") }}
kind: CronJob
metadata:
name: {{ printf "%s-job" .Release.Name }}
labels:
release: {{ .Release.Name }}
role: dataload-cronjob
app: cache
targetDataset: {{ required "targetDataset should be set" .Values.dataloader.targetDataset }}
dataload: {{ .Values.name }}
fluid.io/jobPolicy: cron
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
schedule: "{{ .Values.dataloader.schedule }}"
jobTemplate:
spec:
backoffLimit: {{ .Values.dataloader.backoffLimit | default "3" }}
completions: 1
parallelism: 1
template:
metadata:
name: {{ printf "%s-loader" .Release.Name }}
annotations:
sidecar.istio.io/inject: "false"
{{- if .Values.dataloader.annotations }}
{{- range $key, $val := .Values.dataloader.annotations }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
labels:
release: {{ .Release.Name }}
role: dataload-pod
app: cache
cronjob: {{ printf "%s-job" .Release.Name }}
targetDataset: {{ required "targetDataset should be set" .Values.dataloader.targetDataset }}
{{- include "library.fluid.labels" . | nindent 12 }}
{{- if .Values.dataloader.labels }}
{{- range $key, $val := .Values.dataloader.labels }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
{{- include "library.fluid.dataload.cronJobCommonTemplateSpec" . | nindent 10 }}
containers:
- name: dataloader
image: {{ required "Dataloader image should be set" .Values.dataloader.image }}
imagePullPolicy: IfNotPresent
command:
{{- range .Values.dataloader.command }}
- {{ . | quote }}
{{- end }}
args:
Comment thread
xliuqq marked this conversation as resolved.
{{- range .Values.dataloader.args }}
- {{ . | quote }}
{{- end }}

{{- if .Values.dataloader.resources }}
resources:
{{- toYaml .Values.dataloader.resources | nindent 16}}

Check warning on line 69 in charts/fluid-dataloader/cache/templates/cronjob.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a whitespace before "}}" in the template directive.

See more on https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&issues=AZ2pw6POWXwdTZN177ee&open=AZ2pw6POWXwdTZN177ee&pullRequest=5798
{{- end }}
{{- $targetPaths := "" }}
{{- range .Values.dataloader.targetPaths }}
{{- $targetPaths = cat $targetPaths (required "Path must be set" .path) ":" }}
{{- end }}
{{- $targetPaths = $targetPaths | nospace | trimSuffix ":" }}

{{- $pathReplicas := ""}}

Check warning on line 77 in charts/fluid-dataloader/cache/templates/cronjob.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a whitespace before "}}" in the template directive.

See more on https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&issues=AZ2pw6POWXwdTZN177ef&open=AZ2pw6POWXwdTZN177ef&pullRequest=5798
{{- range .Values.dataloader.targetPaths }}
{{- $pathReplicas = cat $pathReplicas ( default 1 .replicas ) ":"}}

Check warning on line 79 in charts/fluid-dataloader/cache/templates/cronjob.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a whitespace before "}}" in the template directive.

See more on https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&issues=AZ2pw6POWXwdTZN177eg&open=AZ2pw6POWXwdTZN177eg&pullRequest=5798
{{- end }}
{{- $pathReplicas = $pathReplicas | nospace | trimSuffix ":"}}

Check warning on line 81 in charts/fluid-dataloader/cache/templates/cronjob.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a whitespace before "}}" in the template directive.

See more on https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&issues=AZ2pw6POWXwdTZN177eh&open=AZ2pw6POWXwdTZN177eh&pullRequest=5798
env:
- name: FLUID_DATALOAD_METADATA
value: {{ default false .Values.dataloader.loadMetadata | quote }}
- name: FLUID_DATALOAD_DATA_PATH
value: {{ $targetPaths | quote }}
- name: FLUID_DATALOAD_PATH_REPLICAS
value: {{ $pathReplicas | quote }}
{{- range .Values.dataloader.envs }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}

{{- end }}
106 changes: 106 additions & 0 deletions charts/fluid-dataloader/cache/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{{- if or (eq (lower .Values.dataloader.policy) "") (eq (lower .Values.dataloader.policy) "once") }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ printf "%s-job" .Release.Name }}
labels:
release: {{ .Release.Name }}
role: dataload-job
app: cache
targetDataset: {{ required "targetDataset should be set" .Values.dataloader.targetDataset }}
{{- include "library.fluid.labels" . | nindent 4 }}
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
backoffLimit: {{ .Values.dataloader.backoffLimit | default "3" }}
completions: 1
parallelism: 1
template:
metadata:
name: {{ printf "%s-loader" .Release.Name }}
annotations:
sidecar.istio.io/inject: "false"
{{- if .Values.dataloader.annotations }}
{{- range $key, $val := .Values.dataloader.annotations }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
labels:
release: {{ .Release.Name }}
role: dataload-pod
app: cache
targetDataset: {{ required "targetDataset should be set" .Values.dataloader.targetDataset }}
{{- include "library.fluid.labels" . | nindent 8 }}
{{- if .Values.dataloader.labels }}
{{- range $key, $val := .Values.dataloader.labels }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.dataloader.schedulerName }}
schedulerName: {{ .Values.dataloader.schedulerName }}
{{- end }}
{{- with .Values.dataloader.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dataloader.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dataloader.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
{{- with .Values.dataloader.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: dataloader
image: {{ required "Dataloader image should be set" .Values.dataloader.image }}
imagePullPolicy: IfNotPresent
command:
{{- range .Values.dataloader.command }}
- {{ . | quote }}
{{- end }}
args:
{{- range .Values.dataloader.args }}
- {{ . | quote }}
{{- end }}

{{- if .Values.dataloader.resources }}
resources:
{{ toYaml .Values.dataloader.resources | nindent 12 }}
{{- end }}
{{- $targetPaths := "" }}
{{- range .Values.dataloader.targetPaths }}
{{- $targetPaths = cat $targetPaths (required "Path must be set" .path) ":" }}
{{- end }}
{{- $targetPaths = $targetPaths | nospace | trimSuffix ":" }}

{{- $pathReplicas := ""}}
{{- range .Values.dataloader.targetPaths }}
{{- $pathReplicas = cat $pathReplicas ( default 1 .replicas ) ":"}}
{{- end }}
{{- $pathReplicas = $pathReplicas | nospace | trimSuffix ":"}}
env:
- name: FLUID_DATALOAD_METADATA
value: {{ default false .Values.dataloader.loadMetadata | quote }}
- name: FLUID_DATALOAD_DATA_PATH
value: {{ $targetPaths | quote }}
- name: FLUID_DATALOAD_PATH_REPLICAS
value: {{ $pathReplicas | quote }}
{{- range .Values.dataloader.envs }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
{{- end }}
Loading
Loading