-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: implement VineyardEngine.CheckRuntimeReady to check worker read… #6106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,15 @@ import ( | |
| "github.com/fluid-cloudnative/fluid/pkg/utils/testutil" | ||
| ) | ||
|
|
||
| // CheckRuntimeReady checks if the VineyardRuntime is ready to serve data operations. | ||
| // Readiness is determined by worker availability. Fuse components are intentionally | ||
| // excluded because fluid treats fuse as always-ready by design (see pkg/ctrl/fuse.go). | ||
| func (e *VineyardEngine) CheckRuntimeReady() (ready bool) { | ||
| //TODO implement me | ||
| return true | ||
| workerReady, err := e.CheckWorkersReady() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delegating to |
||
| if err != nil { | ||
| return false | ||
| } | ||
| return workerReady | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth calling out: |
||
| } | ||
|
|
||
| // getRuntimeInfo gets runtime info | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,14 @@ import ( | |
|
|
||
| "github.com/fluid-cloudnative/fluid/api/v1alpha1" | ||
| "github.com/fluid-cloudnative/fluid/pkg/common" | ||
| ctrlhelper "github.com/fluid-cloudnative/fluid/pkg/ctrl" | ||
| "github.com/fluid-cloudnative/fluid/pkg/ddc/base" | ||
| "github.com/fluid-cloudnative/fluid/pkg/utils/fake" | ||
| v1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/utils/ptr" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| ) | ||
|
|
||
|
|
@@ -181,3 +183,87 @@ func TestGetRuntimeInfo(t *testing.T) { | |
| } | ||
| } | ||
| } | ||
|
|
||
| func TestVineyardEngineCheckRuntimeReady(t *testing.T) { | ||
| testcases := []struct { | ||
| name string | ||
| workerSS *v1.StatefulSet | ||
| runtime *v1alpha1.VineyardRuntime | ||
| expectedReady bool | ||
| }{ | ||
| { | ||
| name: "workers ready returns true", | ||
| workerSS: &v1.StatefulSet{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "hbase-worker", | ||
| Namespace: "fluid", | ||
| }, | ||
| Spec: v1.StatefulSetSpec{ | ||
| Replicas: ptr.To[int32](1), | ||
| }, | ||
| Status: v1.StatefulSetStatus{ | ||
| Replicas: 1, | ||
| ReadyReplicas: 1, | ||
| AvailableReplicas: 1, | ||
| }, | ||
| }, | ||
| runtime: &v1alpha1.VineyardRuntime{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: "hbase", Namespace: "fluid"}, | ||
| Spec: v1alpha1.VineyardRuntimeSpec{ | ||
| Worker: v1alpha1.VineyardCompTemplateSpec{Replicas: 1}, | ||
| }, | ||
| }, | ||
| expectedReady: true, | ||
| }, | ||
| { | ||
| name: "workers not ready returns false", | ||
| workerSS: &v1.StatefulSet{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "hbase-worker", | ||
| Namespace: "fluid", | ||
| }, | ||
| Spec: v1.StatefulSetSpec{ | ||
| Replicas: ptr.To[int32](1), | ||
| }, | ||
| Status: v1.StatefulSetStatus{ | ||
| Replicas: 1, | ||
| ReadyReplicas: 0, | ||
| AvailableReplicas: 0, | ||
| }, | ||
| }, | ||
| runtime: &v1alpha1.VineyardRuntime{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: "hbase", Namespace: "fluid"}, | ||
| Spec: v1alpha1.VineyardRuntimeSpec{ | ||
| Worker: v1alpha1.VineyardCompTemplateSpec{Replicas: 1}, | ||
| }, | ||
| }, | ||
| expectedReady: false, | ||
| }, | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two test cases cover ready=true and ready=false, but the |
||
|
|
||
| for _, tc := range testcases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| dataset := &v1alpha1.Dataset{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: "hbase", Namespace: "fluid"}, | ||
| } | ||
| objs := []runtime.Object{tc.workerSS, tc.runtime, dataset} | ||
| fakeClient := fake.NewFakeClientWithScheme(testScheme, objs...) | ||
| runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.VineyardRuntime) | ||
| if err != nil { | ||
| t.Fatalf("failed to build runtime info: %v", err) | ||
| } | ||
| engine := &VineyardEngine{ | ||
| Client: fakeClient, | ||
| Log: fake.NullLogger(), | ||
| namespace: "fluid", | ||
| name: "hbase", | ||
| runtime: tc.runtime, | ||
| Helper: ctrlhelper.BuildHelper(runtimeInfo, fakeClient, fake.NullLogger()), | ||
| } | ||
| ready := engine.CheckRuntimeReady() | ||
| if ready != tc.expectedReady { | ||
| t.Errorf("expected ready=%v, got ready=%v", tc.expectedReady, ready) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vineyard's runtime has a real master component (etcd, see
master.go/CheckMasterReady) that stores object metadata, andCheckRuntimeHealthyin this same package explicitly checks master + worker + fuse in that order. Peer engines diverge on this: EFC checks master and worker; JuiceFS checks worker only; Alluxio/Jindo check master only. What's the reasoning for worker-only here? If the invariant 'workers cannot become ready until master is ready' holds in the setup path, please note that in the docstring; otherwise consider following EFC's pattern (master first, then workers) to avoid data operations racing an unhealthy master.