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
28 changes: 21 additions & 7 deletions pkg/ddc/jindo/load_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,27 @@ func (e *JindoEngine) genDataLoadValue(image string, runtime *datav1alpha1.Jindo
}

targetPaths := []cdataload.TargetPath{}
for _, target := range dataload.Spec.Target {
fluidNative := utils.IsTargetPathUnderFluidNativeMounts(target.Path, *targetDataset)
targetPaths = append(targetPaths, cdataload.TargetPath{
Path: target.Path,
Replicas: target.Replicas,
FluidNative: fluidNative,
})
if len(dataload.Spec.Target) > 0 {
for _, target := range dataload.Spec.Target {
fluidNative := utils.IsTargetPathUnderFluidNativeMounts(target.Path, *targetDataset)
targetPaths = append(targetPaths, cdataload.TargetPath{
Path: target.Path,
Replicas: target.Replicas,
FluidNative: fluidNative,
})
}
} else {
for _, m := range targetDataset.Spec.Mounts {
if m.Path == "" {
continue
}
fluidNative := utils.IsTargetPathUnderFluidNativeMounts(m.Path, *targetDataset)
targetPaths = append(targetPaths, cdataload.TargetPath{
Path: m.Path,
Replicas: 1,
FluidNative: fluidNative,
})
}
}
dataloadInfo.TargetPaths = targetPaths
options := map[string]string{}
Expand Down
136 changes: 136 additions & 0 deletions pkg/ddc/jindo/load_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,142 @@ func Test_genDataLoadValue(t *testing.T) {
runtime *datav1alpha1.JindoRuntime
want *cdataload.DataLoadValue
}{
"dataset without mounts and no explicit target": {
image: "fluid:v0.0.1",
targetDataset: &datav1alpha1.Dataset{
ObjectMeta: metav1.ObjectMeta{
Name: "test-dataset",
Namespace: "fluid",
},
Spec: datav1alpha1.DatasetSpec{},
},
dataload: &datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{
Name: "test-dataload",
Namespace: "fluid",
},
Spec: datav1alpha1.DataLoadSpec{
Dataset: datav1alpha1.TargetDataset{
Name: "test-dataset",
Namespace: "fluid",
},
},
},
runtime: &datav1alpha1.JindoRuntime{
Spec: datav1alpha1.JindoRuntimeSpec{
TieredStore: datav1alpha1.TieredStore{
Levels: []datav1alpha1.Level{
{
MediumType: "MEM",
},
},
},
HadoopConfig: "principal=root",
},
},
want: &cdataload.DataLoadValue{
Name: "test-dataload",
OwnerDatasetId: "fluid-test-dataset",
Owner: &common.OwnerReference{
APIVersion: "/",
Enabled: true,
Name: "test-dataload",
BlockOwnerDeletion: false,
Controller: true,
},
DataLoadInfo: cdataload.DataLoadInfo{
BackoffLimit: 3,
Image: "fluid:v0.0.1",
TargetDataset: "test-dataset",
TargetPaths: []cdataload.TargetPath{},
ImagePullSecrets: []corev1.LocalObjectReference{},
Options: map[string]string{
"loadMemorydata": "true",
"hdfsConfig": "principal=root",
},
},
},
},
"dataset with multiple mounts and no explicit target": {
image: "fluid:v0.0.1",
targetDataset: &datav1alpha1.Dataset{
ObjectMeta: metav1.ObjectMeta{
Name: "test-dataset",
Namespace: "fluid",
},
Spec: datav1alpha1.DatasetSpec{
Mounts: []datav1alpha1.Mount{
{
Name: "spark-0",
MountPoint: "local://mnt/data0",
Path: "/mnt0",
},
{
Name: "spark-1",
MountPoint: "local://mnt/data1",
Path: "/mnt1",
},
},
},
},
dataload: &datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{
Name: "test-dataload",
Namespace: "fluid",
},
Spec: datav1alpha1.DataLoadSpec{
Dataset: datav1alpha1.TargetDataset{
Name: "test-dataset",
Namespace: "fluid",
},
},
},
runtime: &datav1alpha1.JindoRuntime{
Spec: datav1alpha1.JindoRuntimeSpec{
TieredStore: datav1alpha1.TieredStore{
Levels: []datav1alpha1.Level{
{
MediumType: "MEM",
},
},
},
HadoopConfig: "principal=root",
},
},
want: &cdataload.DataLoadValue{
Name: "test-dataload",
OwnerDatasetId: "fluid-test-dataset",
Owner: &common.OwnerReference{
APIVersion: "/",
Enabled: true,
Name: "test-dataload",
BlockOwnerDeletion: false,
Controller: true,
},
DataLoadInfo: cdataload.DataLoadInfo{
BackoffLimit: 3,
Image: "fluid:v0.0.1",
TargetDataset: "test-dataset",
TargetPaths: []cdataload.TargetPath{
{
Path: "/mnt0",
Replicas: 1,
FluidNative: true,
},
{
Path: "/mnt1",
Replicas: 1,
FluidNative: true,
},
},
ImagePullSecrets: []corev1.LocalObjectReference{},
Options: map[string]string{
"loadMemorydata": "true",
"hdfsConfig": "principal=root",
},
},
},
},
"test case with scheduler name": {
image: "fluid:v0.0.1",
targetDataset: &datav1alpha1.Dataset{
Expand Down