From a4bb7da8919967d3b3e0a98ac2c0d257c234e16d Mon Sep 17 00:00:00 2001 From: cheyang Date: Thu, 3 Feb 2022 19:22:34 +0800 Subject: [PATCH] Make AlluxioRuntime support serverless (#1411) * Support Alluxio, To #37688693 Signed-off-by: cheyang * Support Alluxio, To #37688693 Signed-off-by: cheyang * Support Alluxio, To #37688693 Signed-off-by: cheyang Signed-off-by: zwwhdls --- charts/fluid/fluid/Chart.yaml | 2 +- charts/fluid/fluid/values.yaml | 20 +++---- pkg/ddc/base/runtime_helper.go | 7 ++- pkg/ddc/base/runtime_helper_test.go | 82 ++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 16 deletions(-) diff --git a/charts/fluid/fluid/Chart.yaml b/charts/fluid/fluid/Chart.yaml index 9df641847de..08254e80b70 100644 --- a/charts/fluid/fluid/Chart.yaml +++ b/charts/fluid/fluid/Chart.yaml @@ -18,7 +18,7 @@ version: 0.7.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. -appVersion: 0.7.0-6997fad +appVersion: 0.7.0-73135a0 home: https://github.com/fluid-cloudnative/fluid keywords: - category:data diff --git a/charts/fluid/fluid/values.yaml b/charts/fluid/fluid/values.yaml index b3541a24891..22134fae220 100644 --- a/charts/fluid/fluid/values.yaml +++ b/charts/fluid/fluid/values.yaml @@ -6,7 +6,7 @@ workdir: /tmp dataset: controller: - image: fluidcloudnative/dataset-controller:v0.7.0-6997fad + image: fluidcloudnative/dataset-controller:v0.7.0-73135a0 csi: recoverFusePeriod: -1 @@ -15,7 +15,7 @@ csi: registrar: image: registry.aliyuncs.com/acs/csi-node-driver-registrar:v1.2.0 plugins: - image: fluidcloudnative/fluid-csi:v0.7.0-6997fad + image: fluidcloudnative/fluid-csi:v0.7.0-73135a0 kubelet: rootDir: /var/lib/kubelet @@ -28,9 +28,9 @@ runtime: portRange: 20000-26000 enabled: true init: - image: fluidcloudnative/init-users:v0.7.0-6997fad + image: fluidcloudnative/init-users:v0.7.0-73135a0 controller: - image: fluidcloudnative/alluxioruntime-controller:v0.7.0-6997fad + image: fluidcloudnative/alluxioruntime-controller:v0.7.0-73135a0 runtime: image: registry.aliyuncs.com/alluxio/alluxio:release-2.7.2-SNAPSHOT-3714f2b fuse: @@ -44,19 +44,19 @@ runtime: fuse: image: registry.cn-shanghai.aliyuncs.com/jindofs/jindo-fuse:3.8.0 controller: - image: fluidcloudnative/jindoruntime-controller:v0.7.0-6997fad + image: fluidcloudnative/jindoruntime-controller:v0.7.0-73135a0 init: portCheck: enabled: false - image: fluidcloudnative/init-users:v0.7.0-6997fad + image: fluidcloudnative/init-users:v0.7.0-73135a0 goosefs: runtimeWorkers: 3 portRange: 26000-32000 enabled: false init: - image: fluidcloudnative/init-users:v0.7.0-6997fad + image: fluidcloudnative/init-users:v0.7.0-73135a0 controller: - image: fluidcloudnative/goosefsruntime-controller:v0.7.0-6997fad + image: fluidcloudnative/goosefsruntime-controller:v0.7.0-73135a0 runtime: image: ccr.ccs.tencentyun.com/qcloud/goosefs:v1.1.0-kona_jdk11 fuse: @@ -64,12 +64,12 @@ runtime: juicefs: enabled: false controller: - image: fluidcloudnative/juicefsruntime-controller:v0.7.0-6997fad + image: fluidcloudnative/juicefsruntime-controller:v0.7.0-73135a0 fuse: image: juicedata/juicefs-csi-driver:v0.11.0 webhook: enabled: true - image: fluidcloudnative/fluid-webhook:v0.7.0-6997fad + image: fluidcloudnative/fluid-webhook:v0.7.0-73135a0 replicas: 1 diff --git a/pkg/ddc/base/runtime_helper.go b/pkg/ddc/base/runtime_helper.go index 915eb6ee061..f5e1186a729 100644 --- a/pkg/ddc/base/runtime_helper.go +++ b/pkg/ddc/base/runtime_helper.go @@ -119,13 +119,12 @@ func (info *RuntimeInfo) getFuseDaemonset() (ds *appsv1.DaemonSet, err error) { return } - chartName := "" + var fuseName string switch info.runtimeType { case common.JindoRuntime: - chartName = common.JindoChartName + fuseName = info.name + "-" + common.JindoChartName + "-fuse" default: - chartName = info.runtimeType + fuseName = info.name + "-fuse" } - fuseName := info.name + "-" + chartName + "-fuse" return kubeclient.GetDaemonset(info.client, fuseName, info.GetNamespace()) } diff --git a/pkg/ddc/base/runtime_helper_test.go b/pkg/ddc/base/runtime_helper_test.go index 2881e257b41..ffc42f20e81 100644 --- a/pkg/ddc/base/runtime_helper_test.go +++ b/pkg/ddc/base/runtime_helper_test.go @@ -22,6 +22,7 @@ import ( datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1" "github.com/fluid-cloudnative/fluid/pkg/common" "github.com/fluid-cloudnative/fluid/pkg/utils/fake" + "sigs.k8s.io/controller-runtime/pkg/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -196,7 +197,7 @@ func TestGetTemplateToInjectForFuse(t *testing.T) { }, fuse: &appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "dataset1-alluxio-fuse", + Name: "dataset1-fuse", Namespace: "big-data", }, Spec: appsv1.DaemonSetSpec{ @@ -500,3 +501,82 @@ func TestGetTemplateToInjectForFuse(t *testing.T) { } } } + +func TestGetFuseDaemonset(t *testing.T) { + type testCase struct { + name string + namespace string + runtimeType string + ds *appsv1.DaemonSet + setClient bool + wantErr bool + } + + tests := []testCase{ + { + name: "alluxio", + namespace: "default", + runtimeType: common.ALLUXIO_RUNTIME, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "alluxio-fuse", + Namespace: "default", + }, + }, + setClient: true, + wantErr: false, + }, { + name: "jindo", + namespace: "default", + runtimeType: common.JindoRuntime, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "jindo-jindofs-fuse", + Namespace: "default", + }, + }, + setClient: true, + wantErr: false, + }, { + name: "noclient", + namespace: "default", + runtimeType: common.JindoRuntime, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "jindo-jindofs-fuse", + Namespace: "default", + }, + }, + setClient: false, + wantErr: true, + }, + } + + for _, test := range tests { + var fakeClient client.Client + if test.setClient { + objs := []runtime.Object{} + s := runtime.NewScheme() + _ = corev1.AddToScheme(s) + _ = datav1alpha1.AddToScheme(s) + _ = appsv1.AddToScheme(s) + objs = append(objs, test.ds) + fakeClient = fake.NewFakeClientWithScheme(s, objs...) + } + + runtimeInfo := RuntimeInfo{ + name: test.name, + namespace: test.namespace, + runtimeType: test.runtimeType, + } + + if fakeClient != nil { + runtimeInfo.SetClient(fakeClient) + } + + _, err := runtimeInfo.getFuseDaemonset() + if (err == nil) == test.wantErr { + t.Errorf("testcase %s is failed, want err %v, got err %v", test.name, test.wantErr, err) + } + } +}