Skip to content
Merged
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
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/deprecated_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func getTestAlluxioEngine(client client.Client, name string, namespace string) *
// - name (string): The name of the resource.
// - suffix (string): The suffix of the label, which is not used in this test case.
//
// This test checks various combinations of `namespace` and `name`,
// This test checks various combinations of `namespace` and `name`,
// and validates whether the generated label name matches the expected output, ensuring the function logic is correct.
func TestAlluxioEngine_GetDeprecatedCommonLabelname(t *testing.T) {
testCases := []struct {
Expand Down
26 changes: 7 additions & 19 deletions pkg/ddc/juicefs/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ import (

"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"

corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/util/retry"

datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/utils"
)

func (j JuiceFSEngine) CheckMasterReady() (ready bool, err error) {
// JuiceFS Runtime has no master role
return true, nil
}

// ShouldSetupMaster checks if a further call of func `SetupMaster` is needed.
// JuiceFS Runtime has no master role, so the function check runtime.status.WorkerPhase
// to know if juicefs is installed and set up.
func (j JuiceFSEngine) ShouldSetupMaster() (should bool, err error) {
runtime, err := j.getRuntime()
if err != nil {
Expand All @@ -50,6 +51,9 @@ func (j JuiceFSEngine) ShouldSetupMaster() (should bool, err error) {
return
}

// SetupMaster installs juicefs components into the cluster.
// JuiceFS Runtime has no master role, implementing func `SetupMaster` here
// is just for a same lifecycle as other runtimes (other runtimes may have master component)
func (j JuiceFSEngine) SetupMaster() (err error) {
workerName := j.getWorkerName()

Expand All @@ -58,7 +62,7 @@ func (j JuiceFSEngine) SetupMaster() (err error) {
if err != nil && apierrs.IsNotFound(err) {
//1. Is not found error
j.Log.V(1).Info("SetupMaster", "worker", workerName)
return j.setupMasterInternal()
return j.installJuiceFS()
} else if err != nil {
//2. Other errors
return
Expand All @@ -75,26 +79,10 @@ func (j JuiceFSEngine) SetupMaster() (err error) {
}
runtimeToUpdate := runtime.DeepCopy()

runtimeToUpdate.Status.WorkerPhase = datav1alpha1.RuntimePhaseNotReady
replicas := runtimeToUpdate.Spec.Worker.Replicas
if replicas == 0 {
replicas = 1
}

// Init selector for worker
runtimeToUpdate.Status.Selector = j.getWorkerSelectors()
runtimeToUpdate.Status.DesiredWorkerNumberScheduled = replicas
runtimeToUpdate.Status.ValueFileConfigmap = j.getHelmValuesConfigMapName()

if len(runtimeToUpdate.Status.Conditions) == 0 {
runtimeToUpdate.Status.Conditions = []datav1alpha1.RuntimeCondition{}
}
cond := utils.NewRuntimeCondition(datav1alpha1.RuntimeWorkersInitialized, datav1alpha1.RuntimeWorkersInitializedReason,
"The worker is initialized.", corev1.ConditionTrue)
runtimeToUpdate.Status.Conditions =
utils.UpdateRuntimeCondition(runtimeToUpdate.Status.Conditions,
cond)

if !reflect.DeepEqual(runtime.Status, runtimeToUpdate.Status) {
return j.Client.Status().Update(context.TODO(), runtimeToUpdate)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/ddc/juicefs/master_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import (
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
)

// setup fuse
func (j *JuiceFSEngine) setupMasterInternal() (err error) {
func (j *JuiceFSEngine) installJuiceFS() (err error) {
var (
chartName = utils.GetChartsDirectory() + "/" + common.JuiceFSChart
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/ddc/juicefs/master_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestSetupMasterInternal(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
err = engine.setupMasterInternal()
err = engine.installJuiceFS()
if err != nil {
t.Errorf("fail to exec check helm release: %v", err)
}
Expand All @@ -164,7 +164,7 @@ func TestSetupMasterInternal(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
err = engine.setupMasterInternal()
err = engine.installJuiceFS()
if err == nil {
t.Errorf("fail to catch the error: %v", err)
}
Expand All @@ -181,7 +181,7 @@ func TestSetupMasterInternal(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
err = engine.setupMasterInternal()
err = engine.installJuiceFS()
if err == nil {
t.Errorf("fail to catch the error")
}
Expand All @@ -192,7 +192,7 @@ func TestSetupMasterInternal(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
err = engine.setupMasterInternal()
err = engine.installJuiceFS()
fmt.Println(err)
if err != nil {
t.Errorf("fail to install release")
Expand Down
9 changes: 0 additions & 9 deletions pkg/ddc/juicefs/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ func TestJuiceFSEngine_SetupMaster(t *testing.T) {
t.Errorf("fail to exec the func with error %v", err)
return
}
juicefsruntime, err := test.engine.getRuntime()
if err != nil {
t.Errorf("fail to get the runtime")
return
}
if juicefsruntime.Status.WorkerPhase == datav1alpha1.RuntimePhaseNone {
t.Errorf("fail to update the runtime")
return
}
}
}

Expand Down
Loading