From e4f913ccae6c476b29333c30cc10a48a7b2becd1 Mon Sep 17 00:00:00 2001 From: trafalgarzzz Date: Tue, 6 Aug 2024 17:36:36 +0800 Subject: [PATCH] bugfix: Support data process operation type for JindoCache engine Signed-off-by: trafalgarzzz --- pkg/ddc/jindocache/operate.go | 18 ++++++++----- pkg/ddc/jindocache/process_data.go | 43 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 pkg/ddc/jindocache/process_data.go diff --git a/pkg/ddc/jindocache/operate.go b/pkg/ddc/jindocache/operate.go index 624b9ed7289..aa8c15ce3df 100644 --- a/pkg/ddc/jindocache/operate.go +++ b/pkg/ddc/jindocache/operate.go @@ -27,14 +27,18 @@ func (e *JindoCacheEngine) GetDataOperationValueFile(ctx cruntime.ReconcileReque operationType := operation.GetOperationType() object := operation.GetOperationObject() - if operationType == dataoperation.DataLoadType { + switch operationType { + case dataoperation.DataLoadType: valueFileName, err = e.generateDataLoadValueFile(ctx, object) return valueFileName, err + case dataoperation.DataProcessType: + valueFileName, err = e.generateDataProcessValueFile(ctx, object) + return valueFileName, err + default: + return "", errors.NewNotSupported( + schema.GroupResource{ + Group: object.GetObjectKind().GroupVersionKind().Group, + Resource: object.GetObjectKind().GroupVersionKind().Kind, + }, "JindoRuntime") } - - return "", errors.NewNotSupported( - schema.GroupResource{ - Group: object.GetObjectKind().GroupVersionKind().Group, - Resource: object.GetObjectKind().GroupVersionKind().Kind, - }, "JindoRuntime") } diff --git a/pkg/ddc/jindocache/process_data.go b/pkg/ddc/jindocache/process_data.go new file mode 100644 index 00000000000..666937ab3b4 --- /dev/null +++ b/pkg/ddc/jindocache/process_data.go @@ -0,0 +1,43 @@ +/* + Copyright 2023 The Fluid Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package jindocache + +import ( + "fmt" + + datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1" + "github.com/fluid-cloudnative/fluid/pkg/dataprocess" + cruntime "github.com/fluid-cloudnative/fluid/pkg/runtime" + "github.com/fluid-cloudnative/fluid/pkg/utils" + "github.com/pkg/errors" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func (e *JindoCacheEngine) generateDataProcessValueFile(ctx cruntime.ReconcileRequestContext, object client.Object) (valueFileName string, err error) { + dataProcess, ok := object.(*datav1alpha1.DataProcess) + if !ok { + err = fmt.Errorf("object %v is not of type DataProcess", object) + return "", err + } + + targetDataset, err := utils.GetDataset(e.Client, dataProcess.Spec.Dataset.Name, dataProcess.Spec.Dataset.Namespace) + if err != nil { + return "", errors.Wrap(err, "failed to get dataset") + } + + return dataprocess.GenDataProcessValueFile(e.Client, targetDataset, dataProcess) +}