-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: implement ThinEngine.CheckRuntimeReady to check actual runtime state #6062
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
075c0ec
b79642c
9448a59
92860f5
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 |
|---|---|---|
|
|
@@ -605,4 +605,163 @@ var _ = Describe("ThinEngine Health Check", Label("pkg.ddc.thin.health_check_tes | |
| Expect(count).To(BeEmpty()) | ||
| }) | ||
| }) | ||
|
|
||
| Describe("CheckRuntimeReady", func() { | ||
| Context("when workers and fuse are both ready", func() { | ||
| It("returns true", func() { | ||
| healthyFuse := &appsv1.DaemonSet{ | ||
|
Comment on lines
+609
to
+612
|
||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase + "-fuse", | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Status: appsv1.DaemonSetStatus{ | ||
| NumberUnavailable: 0, | ||
| NumberReady: 1, | ||
| NumberAvailable: 1, | ||
| }, | ||
| } | ||
| healthyWorker := &appsv1.StatefulSet{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase + "-worker", | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Status: appsv1.StatefulSetStatus{ | ||
| Replicas: 1, | ||
| ReadyReplicas: 1, | ||
| AvailableReplicas: 1, | ||
| }, | ||
| } | ||
| runtimeObj := &datav1alpha1.ThinRuntime{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Spec: datav1alpha1.ThinRuntimeSpec{ | ||
| Replicas: 1, | ||
| Worker: datav1alpha1.ThinCompTemplateSpec{ | ||
| Enabled: true, | ||
| }, | ||
| }, | ||
| } | ||
| datasetObj := &datav1alpha1.Dataset{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| } | ||
| c := fake.NewFakeClientWithScheme(testScheme, healthyFuse, healthyWorker, runtimeObj, datasetObj) | ||
| runtimeInfo, err := base.BuildRuntimeInfo(healthCheckTestHbase, healthCheckTestNamespace, common.ThinRuntime) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| engine := ThinEngine{ | ||
| Client: c, | ||
| Log: fake.NullLogger(), | ||
| namespace: healthCheckTestNamespace, | ||
| name: healthCheckTestHbase, | ||
| runtime: runtimeObj, | ||
| Helper: ctrl.BuildHelper(runtimeInfo, c, fake.NullLogger()), | ||
| } | ||
|
|
||
| ready := engine.CheckRuntimeReady() | ||
| Expect(ready).To(BeTrue()) | ||
| }) | ||
| }) | ||
|
|
||
| Context("when workers are not ready", func() { | ||
| It("returns false", func() { | ||
| healthyFuse := &appsv1.DaemonSet{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase + "-fuse", | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Status: appsv1.DaemonSetStatus{ | ||
| NumberUnavailable: 0, | ||
| NumberReady: 1, | ||
| NumberAvailable: 1, | ||
| }, | ||
| } | ||
| notReadyWorker := &appsv1.StatefulSet{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase + "-worker", | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Spec: appsv1.StatefulSetSpec{ | ||
| Replicas: ptr.To[int32](1), | ||
| }, | ||
| Status: appsv1.StatefulSetStatus{ | ||
| Replicas: 1, | ||
| ReadyReplicas: 0, | ||
| AvailableReplicas: 0, | ||
| }, | ||
| } | ||
| runtimeObj := &datav1alpha1.ThinRuntime{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Spec: datav1alpha1.ThinRuntimeSpec{ | ||
| Replicas: 1, | ||
| Worker: datav1alpha1.ThinCompTemplateSpec{ | ||
| Enabled: true, | ||
| }, | ||
| }, | ||
| } | ||
| datasetObj := &datav1alpha1.Dataset{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestHbase, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| } | ||
| c := fake.NewFakeClientWithScheme(testScheme, healthyFuse, notReadyWorker, runtimeObj, datasetObj) | ||
| runtimeInfo, err := base.BuildRuntimeInfo(healthCheckTestHbase, healthCheckTestNamespace, common.ThinRuntime) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| engine := ThinEngine{ | ||
| Client: c, | ||
| Log: fake.NullLogger(), | ||
| namespace: healthCheckTestNamespace, | ||
| name: healthCheckTestHbase, | ||
| runtime: runtimeObj, | ||
| Helper: ctrl.BuildHelper(runtimeInfo, c, fake.NullLogger()), | ||
| } | ||
|
|
||
| ready := engine.CheckRuntimeReady() | ||
| Expect(ready).To(BeFalse()) | ||
| }) | ||
| }) | ||
|
|
||
|
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 architectural fix in runtime_info.go is right and matches what fluid does elsewhere (pkg/ctrl/fuse.go hard-codes fuse ready=true). The problem is this test file: your PR comment says the two fuse tests were removed, but |
||
| Context("when worker is disabled (fuse-only runtime)", func() { | ||
| It("returns true because fluid treats fuse as always-ready", func() { | ||
| // ThinRuntime with no worker enabled: isWorkerEnable() returns false, | ||
| // so CheckWorkersReady() short-circuits to (true, nil). | ||
| // Fuse is intentionally excluded from CheckRuntimeReady because | ||
| // fluid assumes fuse components are always ready (pkg/ctrl/fuse.go). | ||
| runtimeObj := &datav1alpha1.ThinRuntime{ | ||
|
Comment on lines
+731
to
+737
|
||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestSpark, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| Spec: datav1alpha1.ThinRuntimeSpec{}, | ||
| } | ||
| datasetObj := &datav1alpha1.Dataset{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: healthCheckTestSpark, | ||
| Namespace: healthCheckTestNamespace, | ||
| }, | ||
| } | ||
| c := fake.NewFakeClientWithScheme(testScheme, runtimeObj, datasetObj) | ||
| runtimeInfo, err := base.BuildRuntimeInfo(healthCheckTestSpark, healthCheckTestNamespace, common.ThinRuntime) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| engine := ThinEngine{ | ||
| Client: c, | ||
| Log: fake.NullLogger(), | ||
| namespace: healthCheckTestNamespace, | ||
| name: healthCheckTestSpark, | ||
| runtime: runtimeObj, | ||
| Helper: ctrl.BuildHelper(runtimeInfo, c, fake.NullLogger()), | ||
| } | ||
|
|
||
| ready := engine.CheckRuntimeReady() | ||
| Expect(ready).To(BeTrue()) | ||
| }) | ||
| }) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,16 @@ import ( | |
| "github.com/fluid-cloudnative/fluid/pkg/utils/testutil" | ||
| ) | ||
|
|
||
| // CheckRuntimeReady checks if the ThinRuntime is ready to serve data operations. | ||
| // Unlike Alluxio/Jindo which probe a master pod, ThinRuntime has no master component, | ||
| // so 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 (t *ThinEngine) CheckRuntimeReady() (ready bool) { | ||
|
Comment on lines
+25
to
29
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. ThinRuntime is typically fuse-only in production — That doesn't really match what callers of Two ways to close this:
The doc comment "readiness is determined by worker availability" also frames worker-mode as the primary path — for ThinRuntime it's the exception. Worth being explicit that with |
||
| //TODO implement me | ||
| return true | ||
| workerReady, err := t.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. Alluxio and Jindo implement |
||
| if err != nil { | ||
| return 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. Consider adding a
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. Consider adding |
||
| } | ||
| return workerReady | ||
| } | ||
|
|
||
| // getRuntimeInfo gets runtime info | ||
|
|
||
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.
Once the failing tests are cleaned up, a small
It()that builds a ThinRuntime withSpec.Worker.Enabled = falseand assertsCheckRuntimeReady()returns true would document the intentional short-circuit inCheckWorkersReadyand guard against future regressions.