Skip to content

feat(helm): Add scheduler service to the Helm chart.#403

Open
20001020ycx wants to merge 16 commits into
y-scope:mainfrom
20001020ycx:feat/2026-07-16-helm-scheduler
Open

feat(helm): Add scheduler service to the Helm chart.#403
20001020ycx wants to merge 16 commits into
y-scope:mainfrom
20001020ycx:feat/2026-07-16-helm-scheduler

Conversation

@20001020ycx

@20001020ycx 20001020ycx commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds the scheduler service so helm install brings up storage + scheduler, with the scheduler registering and polling storage for submitted jobs.

Note

Part of the ongoing Spider Huntsman Kubernetes integration. Up to this PR, Helm chart has storage + database and scheduler, leaving execution manager, and task executor to be integrated in the follow-up PRs.

Note

This PR needs review from two teams:

  • Cloud Team: Please review the Helm chart itself
  • Spider Team: Please review the user-facing Spider's scheduler configuration. You can leave the rest of the chart to the Cloud reviewer.

Checklist

  • The PR satisfies the [contribution guidelines][yscope-contrib-guidelines].
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  1. Confirm the scheduler registered itself with storage: one row whose ip_address is the scheduler Pod IP and port is the scheduler gRPC port (50052):
  kubectl exec spider-database-0 -- mysql -uspider-user -pspider-password spider-db -e "SELECT * FROM schedulers;"

Expected table:

id ip_address port created_at
3 10.244.0.12 50052 2026-07-15 23:37:36

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a Helm-managed Kubernetes Deployment for the scheduler component.
    • Exposed the scheduler via a gRPC Service, including readiness and liveness checks.
    • Introduced configurable scheduler settings (image, port, connection pool) and round-robin runtime options.
    • Generated scheduler configuration now includes storage connectivity settings.
  • Chores

    • Bumped the Helm chart version to 0.1.2.

@20001020ycx
20001020ycx requested review from a team and sitaowang1998 as code owners July 16, 2026 22:41
@20001020ycx 20001020ycx changed the title feat(helm): Add scheduler service to the Helm chart. (WIP) feat(helm): Add scheduler service to the Helm chart. Jul 16, 2026
@20001020ycx
20001020ycx force-pushed the feat/2026-07-16-helm-scheduler branch 3 times, most recently from 50e28a7 to 3f97d66 Compare July 16, 2026 23:34
Adds the scheduler Deployment, Service, and rendered config so `helm install` brings up
storage + scheduler, with the scheduler registering and polling storage for submitted jobs.

The scheduler's `runtime.host` and `storage_endpoint.host` deserialize into `IpAddr`, so a
render-config initContainer resolves storage's Service DNS to its ClusterIP and injects the
Pod IP (via the Downward API) before the scheduler starts.
@20001020ycx
20001020ycx force-pushed the feat/2026-07-16-helm-scheduler branch from 3f97d66 to db62d43 Compare July 17, 2026 00:08
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Helm chart adds scheduler image and runtime configuration, renders a scheduler ConfigMap entry, and deploys the scheduler with a gRPC Service, health probes, and ConfigMap-mounted configuration. The chart version is updated to 0.1.2.

Changes

Scheduler Helm deployment

Layer / File(s) Summary
Scheduler configuration contract
tools/deployment/spider-helm/values.yaml, tools/deployment/spider-helm/templates/configmap.yaml
Adds scheduler image and runtime values, then renders scheduler and storage configuration into the chart ConfigMap.
Scheduler workload startup
tools/deployment/spider-helm/templates/scheduler-deployment.yaml
Adds a scheduler Deployment that starts spider-scheduler with the mounted configuration, gRPC port, health probes, and ConfigMap volume.
Scheduler service and chart release
tools/deployment/spider-helm/templates/scheduler-service.yaml, tools/deployment/spider-helm/Chart.yaml
Adds a gRPC Service for scheduler pods and updates the chart version to 0.1.2.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HelmValues
  participant ConfigMap
  participant SchedulerDeployment
  participant SchedulerService
  participant Scheduler
  HelmValues->>ConfigMap: Render scheduler.yaml settings
  ConfigMap->>SchedulerDeployment: Supply mounted scheduler.yaml
  SchedulerDeployment->>Scheduler: Start scheduler with gRPC port
  SchedulerService->>Scheduler: Route gRPC traffic to named port
Loading

Possibly related PRs

Suggested reviewers: sitaowang1998, junhaoliao

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the scheduler service to the Helm chart.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@20001020ycx 20001020ycx changed the title (WIP) feat(helm): Add scheduler service to the Helm chart. feat(helm): Add scheduler service to the Helm chart. Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tools/deployment/spider-helm/templates/scheduler-deployment.yaml (2)

70-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Support standard scheduling and resource configuration hooks.

To fully align with the opt-in pattern for configuration overrides, consider rendering standard Helm hooks for resources, nodeSelector, tolerations, and affinity. This enables users to customize scheduling and limits if they define them in their values.yaml, while safely defaulting to nothing if omitted. As per learnings, use an opt-in/CLP-style pattern to render resources and scheduling override blocks rather than relying on implicit/hardcoded constraints.

⚙️ Proposed addition of configuration hooks

For example, appending these blocks to the container and pod specs enables the opt-in pattern (adjust the .Values.* paths depending on how you plan to namespace them in your values):

           livenessProbe:
             {{- include "spider.livenessProbeTimings" . | nindent 12 }}
             tcpSocket:
               port: "grpc"
+          {{- with .Values.resources }}
+          resources:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+      {{- with .Values.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/deployment/spider-helm/templates/scheduler-deployment.yaml` around
lines 70 - 74, Update the scheduler Deployment template around the container and
pod specifications to conditionally render Helm values for resources,
nodeSelector, tolerations, and affinity. Use the chart’s established
opt-in/CLP-style helpers or conditional blocks so each section is emitted only
when configured in values.yaml, otherwise preserving the current unconstrained
defaults.

Source: Learnings


31-35: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a retry loop for DNS resolution to improve startup resilience.

If the storage Service and the scheduler Deployment are created simultaneously (e.g., during helm install), the CoreDNS record may not be instantly resolvable during the pod's first second of life. Using a retry loop prevents unnecessary CrashLoopBackOff events and delays.

🛡️ Proposed refactor for robust DNS resolution
-              storage_ip="$(getent hosts "$STORAGE_HOST" | head -n1 | tr -s ' ' | cut -d' ' -f1)"
-              if [ -z "$storage_ip" ]; then
-                echo "Failed to resolve storage host: $STORAGE_HOST" >&2
-                exit 1
-              fi
+              storage_ip=""
+              attempts=0
+              while [ -z "$storage_ip" ] && [ "$attempts" -lt 15 ]; do
+                storage_ip="$(getent hosts "$STORAGE_HOST" | head -n1 | tr -s ' ' | cut -d' ' -f1)"
+                if [ -z "$storage_ip" ]; then
+                  echo "Waiting for storage host $STORAGE_HOST to be resolvable..." >&2
+                  sleep 2
+                  attempts=$((attempts + 1))
+                fi
+              done
+
+              if [ -z "$storage_ip" ]; then
+                echo "Failed to resolve storage host: $STORAGE_HOST" >&2
+                exit 1
+              fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/deployment/spider-helm/templates/scheduler-deployment.yaml` around
lines 31 - 35, Update the startup DNS-resolution logic around storage_ip in the
scheduler container to retry resolving STORAGE_HOST for a short bounded period
before failing. Keep using the resolved address on success, and only emit the
existing failure message and exit after all retries are exhausted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tools/deployment/spider-helm/templates/scheduler-deployment.yaml`:
- Around line 70-74: Update the scheduler Deployment template around the
container and pod specifications to conditionally render Helm values for
resources, nodeSelector, tolerations, and affinity. Use the chart’s established
opt-in/CLP-style helpers or conditional blocks so each section is emitted only
when configured in values.yaml, otherwise preserving the current unconstrained
defaults.
- Around line 31-35: Update the startup DNS-resolution logic around storage_ip
in the scheduler container to retry resolving STORAGE_HOST for a short bounded
period before failing. Keep using the resolved address on success, and only emit
the existing failure message and exit after all retries are exhausted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a36d880e-f306-4826-b51b-a72efb6b43fa

📥 Commits

Reviewing files that changed from the base of the PR and between 1474f09 and db62d43.

📒 Files selected for processing (5)
  • tools/deployment/spider-helm/Chart.yaml
  • tools/deployment/spider-helm/templates/configmap.yaml
  • tools/deployment/spider-helm/templates/scheduler-deployment.yaml
  • tools/deployment/spider-helm/templates/scheduler-service.yaml
  • tools/deployment/spider-helm/values.yaml

@sitaowang1998 sitaowang1998 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scheduler configuration conforms to the current Spider's structure. Though I strongly suggest we merge #401 first and get rid of the hostname resolution part.

@hoophalab

hoophalab commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Let's merge hostname resolution PR first. I guess the current solution might not work (need a full restart) when a pod is rescheduled to another node and got assigned another IP.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/deployment/spider-helm/templates/scheduler-deployment.yaml (1)

37-44: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add opt-in blocks for resources and scheduling overrides.

The deployment template completely omits the resources, nodeSelector, affinity, and tolerations blocks. Based on learnings, the chart should use an opt-in pattern that renders these blocks only when explicitly set in values.yaml. Leaving them out entirely prevents users from configuring necessary compute limits and pod placement rules.

🔧 Proposed fix (adjust `.Values` paths to match your schema)
           livenessProbe:
             {{- include "spider.livenessProbeTimings" . | nindent 12 }}
             tcpSocket:
               port: "grpc"
+          {{- with .Values.scheduler.resources }}
+          resources:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+      {{- with .Values.scheduler.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.scheduler.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.scheduler.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
       volumes:
         - name: "config"
           configMap:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/deployment/spider-helm/templates/scheduler-deployment.yaml` around
lines 37 - 44, Update the scheduler deployment template around the container and
pod specification to conditionally render resources, nodeSelector, affinity, and
tolerations using the chart’s established values paths. Ensure each block is
emitted only when its corresponding value is explicitly configured, while
preserving valid Helm indentation and existing behavior when unset.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tools/deployment/spider-helm/templates/scheduler-deployment.yaml`:
- Around line 37-44: Update the scheduler deployment template around the
container and pod specification to conditionally render resources, nodeSelector,
affinity, and tolerations using the chart’s established values paths. Ensure
each block is emitted only when its corresponding value is explicitly
configured, while preserving valid Helm indentation and existing behavior when
unset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3266147d-b421-4a48-91dc-a248a9f2980a

📥 Commits

Reviewing files that changed from the base of the PR and between db62d43 and 67d8bbd.

📒 Files selected for processing (2)
  • tools/deployment/spider-helm/templates/configmap.yaml
  • tools/deployment/spider-helm/templates/scheduler-deployment.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants