Skip to content

Commit

Permalink
fix jindoruntime pv fuse global (#747)
Browse files Browse the repository at this point in the history
* fix jindoruntime pv fuse global

* refine some ununsed
  • Loading branch information
frankleaf authored Apr 23, 2021
1 parent 88484d6 commit a3584b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 101 deletions.
2 changes: 1 addition & 1 deletion pkg/ddc/jindo/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jindo
const (
CSI_DRIVER = "fuse.csi.fluid.io"

fluid_PATH = "fluid_path"
//fluid_PATH = "fluid_path"

Mount_TYPE = "mount_type"

Expand Down
109 changes: 9 additions & 100 deletions pkg/ddc/jindo/create_volume.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
package jindo

import (
"context"
"github.com/fluid-cloudnative/fluid/pkg/common"
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
expectedAnnotations = map[string]string{
"CreatedBy": "fluid",
}
volumeHelper "github.com/fluid-cloudnative/fluid/pkg/utils/dataset/volume"
)

// CreateVolume creates volume
Expand Down Expand Up @@ -41,106 +31,25 @@ func (e *JindoEngine) CreateVolume() (err error) {
// createFusePersistentVolume
func (e *JindoEngine) createFusePersistentVolume() (err error) {

runtime, err := e.getRuntimeInfo()
if err != nil {
return err
}

pvName := runtime.GetPersistentVolumeName()

found, err := kubeclient.IsPersistentVolumeExist(e.Client, pvName, expectedAnnotations)
runtimeInfo, err := e.getRuntimeInfo()
if err != nil {
return err
}

if !found {
pv := &corev1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: pvName,
Namespace: e.runtime.Namespace,
Labels: map[string]string{
e.getCommonLabelname(): "true",
},
Annotations: expectedAnnotations,
},
Spec: corev1.PersistentVolumeSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteMany,
},
Capacity: corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("100Gi"),
},
PersistentVolumeSource: corev1.PersistentVolumeSource{
CSI: &corev1.CSIPersistentVolumeSource{
Driver: CSI_DRIVER,
VolumeHandle: pvName,
VolumeAttributes: map[string]string{
fluid_PATH: e.getMountPoint(),
Mount_TYPE: common.JINDO_MOUNT_TYPE,
},
},
},
NodeAffinity: &corev1.VolumeNodeAffinity{
Required: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: e.getCommonLabelname(),
Operator: corev1.NodeSelectorOpIn,
Values: []string{"true"},
},
},
},
},
},
},
},
}

err = e.Client.Create(context.TODO(), pv)
if err != nil {
return err
}
} else {
e.Log.Info("The persistent volume is created", "name", pvName)
}

return err
return volumeHelper.CreatePersistentVolumeForRuntime(e.Client,
runtimeInfo,
e.getMountPoint(),
common.JINDO_RUNTIME,
e.Log)
}

// createFusePersistentVolume
func (e *JindoEngine) createFusePersistentVolumeClaim() (err error) {

found, err := kubeclient.IsPersistentVolumeClaimExist(e.Client, e.runtime.Name, e.runtime.Namespace, expectedAnnotations)
runtimeInfo, err := e.getRuntimeInfo()
if err != nil {
return err
}

if !found {
pvc := &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: e.runtime.Name,
Namespace: e.runtime.Namespace,
Annotations: expectedAnnotations,
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteMany,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("100Gi"),
},
},
},
}

err = e.Client.Create(context.TODO(), pvc)
if err != nil {
return err
}
}

return err
return volumeHelper.CreatePersistentVolumeClaimForRuntime(e.Client, runtimeInfo, e.Log)
}
9 changes: 9 additions & 0 deletions pkg/ddc/jindo/runtime_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ func (e *JindoEngine) getRuntimeInfo() (base.RuntimeInfoInterface, error) {
return e.runtimeInfo, err
}

if runtime.Spec.Fuse.Global {
e.runtimeInfo.SetupFuseDeployMode(runtime.Spec.Fuse.Global, runtime.Spec.Fuse.NodeSelector)
e.Log.Info("Enable global mode for fuse")
} else {
e.Log.Info("Disable global mode for fuse")
}

// Check if the runtime is using deprecated labels
isLabelDeprecated, err := e.HasDeprecatedCommonLabelname()
if err != nil {
Expand Down Expand Up @@ -47,6 +54,8 @@ func (e *JindoEngine) getRuntimeInfo() (base.RuntimeInfoInterface, error) {
}

e.runtimeInfo.SetupWithDataset(dataset)

e.Log.Info("Setup with dataset done", "exclusive", e.runtimeInfo.IsExclusive())
}

return e.runtimeInfo, nil
Expand Down

0 comments on commit a3584b5

Please sign in to comment.