@@ -22,19 +22,20 @@ import (
2222
2323 "github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
2424
25- corev1 "k8s.io/api/core/v1"
2625 apierrs "k8s.io/apimachinery/pkg/api/errors"
2726 "k8s.io/client-go/util/retry"
2827
2928 datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
30- "github.com/fluid-cloudnative/fluid/pkg/utils"
3129)
3230
3331func (j JuiceFSEngine ) CheckMasterReady () (ready bool , err error ) {
3432 // JuiceFS Runtime has no master role
3533 return true , nil
3634}
3735
36+ // ShouldSetupMaster checks if a further call of func `SetupMaster` is needed.
37+ // JuiceFS Runtime has no master role, so the function check runtime.status.WorkerPhase
38+ // to know if juicefs is installed and set up.
3839func (j JuiceFSEngine ) ShouldSetupMaster () (should bool , err error ) {
3940 runtime , err := j .getRuntime ()
4041 if err != nil {
@@ -50,6 +51,9 @@ func (j JuiceFSEngine) ShouldSetupMaster() (should bool, err error) {
5051 return
5152}
5253
54+ // SetupMaster installs juicefs components into the cluster.
55+ // JuiceFS Runtime has no master role, implementing func `SetupMaster` here
56+ // is just for a same lifecycle as other runtimes (other runtimes may have master component)
5357func (j JuiceFSEngine ) SetupMaster () (err error ) {
5458 workerName := j .getWorkerName ()
5559
@@ -58,7 +62,7 @@ func (j JuiceFSEngine) SetupMaster() (err error) {
5862 if err != nil && apierrs .IsNotFound (err ) {
5963 //1. Is not found error
6064 j .Log .V (1 ).Info ("SetupMaster" , "worker" , workerName )
61- return j .setupMasterInternal ()
65+ return j .installJuiceFS ()
6266 } else if err != nil {
6367 //2. Other errors
6468 return
@@ -75,26 +79,10 @@ func (j JuiceFSEngine) SetupMaster() (err error) {
7579 }
7680 runtimeToUpdate := runtime .DeepCopy ()
7781
78- runtimeToUpdate .Status .WorkerPhase = datav1alpha1 .RuntimePhaseNotReady
79- replicas := runtimeToUpdate .Spec .Worker .Replicas
80- if replicas == 0 {
81- replicas = 1
82- }
83-
8482 // Init selector for worker
8583 runtimeToUpdate .Status .Selector = j .getWorkerSelectors ()
86- runtimeToUpdate .Status .DesiredWorkerNumberScheduled = replicas
8784 runtimeToUpdate .Status .ValueFileConfigmap = j .getHelmValuesConfigMapName ()
8885
89- if len (runtimeToUpdate .Status .Conditions ) == 0 {
90- runtimeToUpdate .Status .Conditions = []datav1alpha1.RuntimeCondition {}
91- }
92- cond := utils .NewRuntimeCondition (datav1alpha1 .RuntimeWorkersInitialized , datav1alpha1 .RuntimeWorkersInitializedReason ,
93- "The worker is initialized." , corev1 .ConditionTrue )
94- runtimeToUpdate .Status .Conditions =
95- utils .UpdateRuntimeCondition (runtimeToUpdate .Status .Conditions ,
96- cond )
97-
9886 if ! reflect .DeepEqual (runtime .Status , runtimeToUpdate .Status ) {
9987 return j .Client .Status ().Update (context .TODO (), runtimeToUpdate )
10088 }
0 commit comments