Skip to content

feat(helm): Add execution manager service to the Helm chart. - #411

Merged
sitaowang1998 merged 38 commits into
y-scope:mainfrom
sitaowang1998:helm-worker
Jul 23, 2026
Merged

feat(helm): Add execution manager service to the Helm chart.#411
sitaowang1998 merged 38 commits into
y-scope:mainfrom
sitaowang1998:helm-worker

Conversation

@sitaowang1998

@sitaowang1998 sitaowang1998 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds the execution manager service so helm install brings up all Spider services: database, storage, scheduler, and execution manager.

The chart now:

  • Deploys a configurable number of execution manager replicas.
  • Generates the execution manager configuration with scheduler, storage, liveness, and task executor settings.
  • Adds configurable execution manager image settings.
  • Bumps the Helm chart version to 0.1.3.

Note

Part of the ongoing Spider Huntsman Kubernetes integration.

This PR is the final PR in this series.

Checklist

  • The PR satisfies the contribution 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

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a Helm-managed worker Deployment to run the execution-manager component.
    • Extended Helm values to configure worker replicas and the execution-manager runtime (scheduler/storage connectivity, polling interval, and liveness/heartbeat settings).
    • Automatically generates and mounts the execution-manager configuration via a chart ConfigMap.
  • Chores

    • Bumped the Helm chart version from 0.1.2 to 0.1.3.

sitaowang1998 and others added 26 commits July 15, 2026 23:40
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.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Helm chart adds execution-manager values, renders an execution-manager.yaml ConfigMap entry, and deploys a configurable worker running spider-execution-manager. The chart version changes from 0.1.2 to 0.1.3.

Changes

Execution manager deployment

Layer / File(s) Summary
Execution manager configuration
tools/deployment/spider-helm/values.yaml, tools/deployment/spider-helm/templates/configmap.yaml
Worker image settings, worker replicas, optional environment variables, and execution-manager runtime parameters are added and rendered into execution-manager.yaml.
Worker deployment wiring
tools/deployment/spider-helm/templates/worker-deployment.yaml, tools/deployment/spider-helm/Chart.yaml
A worker Deployment runs spider-execution-manager with the rendered configuration, and the chart version is incremented to 0.1.3.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HelmValues
  participant ConfigMap
  participant WorkerDeployment
  participant SpiderExecutionManager
  HelmValues->>ConfigMap: Render execution-manager settings
  ConfigMap->>WorkerDeployment: Mount execution-manager.yaml
  WorkerDeployment->>SpiderExecutionManager: Start with configuration path
Loading

Possibly related PRs

  • y-scope/spider#384: Adds related Helm chart templates and shared helper patterns used by the worker deployment.
  • y-scope/spider#403: Adds complementary scheduler Helm resources referenced by the execution-manager configuration.
  • y-scope/spider#413: Adds chart publishing workflow behaviour that reads the chart version from Chart.yaml.

Suggested reviewers: 20001020ycx, junhaoliao

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main Helm change: adding the execution manager to the chart.
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.
✨ 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.

# Conflicts:
#	tools/deployment/spider-helm/Chart.yaml
#	tools/deployment/spider-helm/templates/configmap.yaml
#	tools/deployment/spider-helm/values.yaml
@sitaowang1998
sitaowang1998 marked this pull request as ready for review July 22, 2026 02:36
@sitaowang1998
sitaowang1998 requested a review from a team as a code owner July 22, 2026 02:36

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tools/deployment/spider-helm/values.yaml (1)

58-63: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Validate non-zero execution-manager settings at chart input.

The runtime deserializes connection_pool_size and both heartbeat intervals as non-zero types. Helm currently permits 0, allowing a rendered chart to install a worker that exits during startup. Add values.schema.json constraints or Helm fail checks for these fields.

🤖 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/values.yaml` around lines 58 - 63, Validate the
chart inputs for connection_pool_size,
liveness.scheduler_heartbeat_interval_sec, and
liveness.storage_heartbeat_interval_sec so Helm rejects zero or negative values
before deployment. Add appropriate values.schema.json minimum constraints or
equivalent Helm fail checks, while preserving the existing positive defaults.
🤖 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.

Inline comments:
In `@tools/deployment/spider-helm/templates/worker-deployment.yaml`:
- Around line 25-29: Add a checksum annotation under the Deployment pod template
metadata for the ConfigMap containing execution-manager.yaml, using Helm’s
rendered ConfigMap content as the checksum source. Ensure the annotation changes
whenever the ConfigMap changes so Kubernetes creates a new ReplicaSet and
workers receive the updated subPath-mounted configuration.

---

Nitpick comments:
In `@tools/deployment/spider-helm/values.yaml`:
- Around line 58-63: Validate the chart inputs for connection_pool_size,
liveness.scheduler_heartbeat_interval_sec, and
liveness.storage_heartbeat_interval_sec so Helm rejects zero or negative values
before deployment. Add appropriate values.schema.json minimum constraints or
equivalent Helm fail checks, while preserving the existing positive defaults.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b84d932b-2348-4fa0-9295-a574b640b342

📥 Commits

Reviewing files that changed from the base of the PR and between f56c3a0 and 397b981.

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

Comment on lines +25 to +29
volumeMounts:
- name: "config"
mountPath: "/etc/spider/execution-manager.yaml"
subPath: "execution-manager.yaml"
readOnly: true

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the chart files and inspect the worker deployment plus related templates.
git ls-files tools/deployment/spider-helm/templates
printf '\n--- worker-deployment.yaml ---\n'
cat -n tools/deployment/spider-helm/templates/worker-deployment.yaml | sed -n '1,220p'
printf '\n--- configmap-related files ---\n'
fd -a -t f 'configmap.yaml|_helpers.tpl|deployment.yaml' tools/deployment/spider-helm/templates
for f in tools/deployment/spider-helm/templates/configmap.yaml tools/deployment/spider-helm/templates/_helpers.tpl tools/deployment/spider-helm/templates/deployment.yaml; do
  if [ -f "$f" ]; then
    printf '\n--- %s ---\n' "$f"
    cat -n "$f" | sed -n '1,260p'
  fi
done
printf '\n--- search for checksum/config and subPath usage ---\n'
rg -n "checksum/config|subPath:|mountPath:|configmap" tools/deployment/spider-helm -S

Repository: y-scope/spider

Length of output: 11654


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read only the worker deployment file if it is short enough and map the template structure.
wc -l tools/deployment/spider-helm/templates/worker-deployment.yaml
ast-grep outline tools/deployment/spider-helm/templates/worker-deployment.yaml --view expanded

Repository: y-scope/spider

Length of output: 293


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the current Helm chart's values and any rollout annotations already present.
for f in tools/deployment/spider-helm/values.yaml tools/deployment/spider-helm/templates/*.yaml; do
  [ -f "$f" ] || continue
  printf '\n--- %s ---\n' "$f"
  rg -n "checksum|rollout|annotations|subPath|ConfigMap|config" "$f" -n -S
done

Repository: y-scope/spider

Length of output: 729


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether the proposed annotation expression references an existing template path.
python3 - <<'PY'
from pathlib import Path
p = Path('tools/deployment/spider-helm/templates/configmap.yaml')
print(p.exists(), p)
if p.exists():
    print(p.read_text()[:500])
PY

Repository: y-scope/spider

Length of output: 712


Trigger a worker rollout when the ConfigMap changes. This Deployment mounts execution-manager.yaml through subPath, so ConfigMap updates won’t reach running workers. Add a checksum annotation under spec.template.metadata to force a new ReplicaSet when the config changes.

🤖 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/worker-deployment.yaml` around lines
25 - 29, Add a checksum annotation under the Deployment pod template metadata
for the ConfigMap containing execution-manager.yaml, using Helm’s rendered
ConfigMap content as the checksum source. Ensure the annotation changes whenever
the ConfigMap changes so Kubernetes creates a new ReplicaSet and workers receive
the updated subPath-mounted configuration.

Source: MCP tools

@20001020ycx 20001020ycx 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.

I appreciate the effort for the e2e testing in your branch. I think it covers what you have implemented pretty well. However, can you first summarize what you have done in the PR description briefly, I had to ask AI to explain it for me.

Also, a note to myself, we might want to add similar testing as what Sitao did, at least the testing scope, as part of the helm's testing infra. Currently, none is provided.

20001020ycx
20001020ycx previously approved these changes Jul 22, 2026

@20001020ycx 20001020ycx 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.

LGTM, just some nits for you to address.

Comment thread tools/deployment/spider-helm/values.yaml Outdated
Comment thread tools/deployment/spider-helm/templates/configmap.yaml

@LinZhihao-723 LinZhihao-723 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In general, the use of "worker" makes sense to me.
Shall we update the PR title as well?
Still need review from someone with more k8s background.

@20001020ycx

Copy link
Copy Markdown
Contributor

In general, the use of "worker" makes sense to me. Shall we update the PR title as well? Still need review from someone with more k8s background.

I second this proposal, at least worker is the terminology that we use extensively in CLP package integration as well.

hoophalab
hoophalab previously approved these changes Jul 23, 2026

@hoophalab hoophalab 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.

LTGM, some comments.

Comment thread tools/deployment/spider-helm/values.yaml Outdated
task_executor:
bin_path: "/usr/local/bin/spider-task-executor"
inherited_env: []
log_dir: "/tmp/spider/task-executor"

@hoophalab hoophalab Jul 23, 2026

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.

I guess /tmp is meant for disposable files. /var/log/spider/task-executor might be more suitable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The logs are written to stderr, and our goal is to route it into container's stdout. But I'll change the log_dir in case we change the behavior latter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The problem is /var/log is not writtable by a non-root user, such as spider-user. Should we use a user-owned directory?

@hoophalab hoophalab Jul 23, 2026

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.

hmm right. How about ~/.cache/spider/task-executor? But I haven't seen any pod use user home folder for log.

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.

Or maybe we just mount an emptydir to /var/log/spider and set uid so that spider-user is writable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My bad. The logs are written to stderr, and currently redirected to {log_dir}/{em_id}-{executor_id}.log.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

According to an offline discussion with Zhihao, we decided to use /tmp/spider/task-executor/ for now. Next week we will fix the log routing and remove the log_dir entirely.

Comment on lines +20 to +21
containers:
- name: "execution-manager"

@hoophalab hoophalab Jul 23, 2026

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.

Is there any way to inject a liveness probe? I'm not sure how spider is designed: I guess the scheduler will reschedule the job if one worker doesn't respond in X minutes, but will the worker restart automatically if there is an unexpected deadlock in user.so, or the execution manager itself?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

User can set a hard timeout on a task, and task executor will be killed and retried if it exceeds the timeout.

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.

I guess the execution manager could still deadlock and this pod just hangs forever?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good question. For this PR we just assume that it will not hang. We will design and implement a proper liveness hook later.

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the rest lgtm. deferring to @hoophalab 's review

- name: "execution-manager"
image: {{ include "spider.imageRef" (dict "root" . "component" "worker") | quote }}
imagePullPolicy: {{ .Values.image.worker.pullPolicy | quote }}
command: ["spider-execution-manager", "--config", "/etc/spider/execution-manager.yaml"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i believe pod termination skips the graceful path here. Kubernetes uses SIGTERM because the worker image has no STOPSIGNAL, while the binary only awaits ctrl_c() / SIGINT; the scheduler shutdown RPC is therefore bypassed and assignments wait for cutoff recovery.

can we handle SIGTERM in the binary?

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.

i guess this is already tracked in #393?

@LinZhihao-723 LinZhihao-723 Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, we're aware of this issue. We (the Spider team) should try to address it next week.

scheduler_poll_wait_ms: 1000
task_executor:
bin_path: "/usr/local/bin/spider-task-executor"
inherited_env: []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

inherited_env names variables to forward into the task executor, but the Deployment exposes no env / envFrom hook, so operators cannot inject Secret-backed values through the chart. can we expose worker environment configuration alongside this option?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I think this is missed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the key is to allow users to define environment variables in the execution manager container. For now, we can leave inherited_env empty: the current configuration will ensure all the forked processes to automatically inherit the execution manager's environment. We only need to make sure env variables can be passed into the execution manager. @sitaowang1998 @20001020ycx Can you check this?

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.

I think the key is to allow users to define environment variables in the execution manager container.

This is exactly what I am doing in #2408

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.

But I do wonder should we plan out adding some test .so within spider's worker container, such that the spider k8s can be tested as a standalone entity?

Of course, not in this PR, I am okay with leaving it empty in this PR. In fact, this should be left as empty even we have the test.so as the CLP_HOME shall be defined in the container image rather than here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think defining it in image works. Some envs are only known at deployment time. My plan is to add a extra_envs map in values, default to empty, and fill it in worker deployment's env. User can define extra_envs and pass in the values they need.

@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.

♻️ Duplicate comments (1)
tools/deployment/spider-helm/templates/worker-deployment.yaml (1)

32-40: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Roll out workers when execution-manager.yaml changes.

Because the ConfigMap key is mounted through subPath, existing Pods will retain stale configuration after the ConfigMap changes. Add a checksum of the rendered ConfigMap under spec.template.metadata.annotations so Helm creates a new ReplicaSet.

Suggested fix
     metadata:
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
       labels:
🤖 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/worker-deployment.yaml` around lines
32 - 40, Update the worker Pod template metadata annotations in the worker
deployment to include a checksum derived from the rendered ConfigMap containing
execution-manager.yaml. Place the checksum under
spec.template.metadata.annotations so any ConfigMap content change produces a
new ReplicaSet and rolls out workers.
🤖 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.

Duplicate comments:
In `@tools/deployment/spider-helm/templates/worker-deployment.yaml`:
- Around line 32-40: Update the worker Pod template metadata annotations in the
worker deployment to include a checksum derived from the rendered ConfigMap
containing execution-manager.yaml. Place the checksum under
spec.template.metadata.annotations so any ConfigMap content change produces a
new ReplicaSet and rolls out workers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d0d23b3-a6b7-4f94-8eb1-b34bc24c277b

📥 Commits

Reviewing files that changed from the base of the PR and between 274c0a1 and a02bf00.

📒 Files selected for processing (2)
  • tools/deployment/spider-helm/templates/worker-deployment.yaml
  • tools/deployment/spider-helm/values.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.

5 participants