Skip to content

feat(spider-execution-manager): Add the execution-manager binary.#362

Merged
sitaowang1998 merged 6 commits into
y-scope:mainfrom
LinZhihao-723:em-bin
Jun 28, 2026
Merged

feat(spider-execution-manager): Add the execution-manager binary.#362
sitaowang1998 merged 6 commits into
y-scope:mainfrom
LinZhihao-723:em-bin

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Jun 28, 2026

Copy link
Copy Markdown
Member

Description

Summary

This PR adds the spider_execution_manager binary that boots the execution manager: it loads a YAML config, connects the storage, liveness, and scheduler gRPC clients, builds the Runtime, and runs it until Ctrl-C. Along the way it factors the config-loading boilerplate shared with spider-storage into spider-utils (an EndpointConfig, a ConfigError, and a YamlConfig trait), and drops the Arc that the liveness public API previously forced on callers.

New binary (spider-execution-manager/src/bin/execution_manager.rs)

  • Mirrors spider-storage's grpc_server entrypoint: installs the shared non-blocking JSON logger via spider_utils::logging::set_up_logging, then parses a single --config <PATH> argument with clap.
  • Loads Config from the YAML file, builds the storage and scheduler tonic::Endpoints from the config, and connects all three gRPC clients (GrpcStorageClient, GrpcLivenessClient, GrpcSchedulerClient) through the connection pool with the configured connection_pool_size. The liveness client reuses the storage endpoint, since storage hosts the liveness service.
  • Constructs the Runtime from the clients and the derived RuntimeConfig, logs the assigned execution-manager id, then spawns runtime.run() and races it against tokio::signal::ctrl_c() in a tokio::select!. On Ctrl-C it cancels the runtime's token and awaits a graceful shutdown; if the runtime exits on its own first, its result is propagated. Each fallible boot step logs a contextual error before returning.
  • Each failure path is logged via inspect_err so a failed boot surfaces a specific message (config load, endpoint parse, per-client connect, runtime create) rather than a bare error.

Execution-manager config (spider-execution-manager/src/config.rs)

  • Adds Config, deserialized from YAML, holding the advertised host, the storage and scheduler EndpointConfigs, the liveness and task-executor sub-configs, the connection_pool_size, and scheduler_poll_wait_ms.
  • Config::runtime_config() derives the runtime's RuntimeConfig (mapping the liveness heartbeat intervals to Durations and forwarding the task-executor paths). from_yaml_file is provided by the shared YamlConfig trait rather than an inherent method.

Shared config utilities (spider-utils/src/config.rs)

  • Hosts EndpointConfig { host, port } with socket_addr() and endpoint(), the latter building a plaintext-HTTP/2 tonic::Endpoint (IPv6-safe via SocketAddr).
  • Adds ConfigError (Io / Parse) and a YamlConfig trait whose default from_yaml_file opens the file and deserializes it with yaml_serde. A blanket impl<ConfigType: DeserializeOwned> YamlConfig for ConfigType {} gives every deserializable config type the loader for free; callers just bring the trait into scope.
  • spider-storage's ServerConfig drops its inherent from_yaml_file and local ConfigError and adopts the shared trait, so the two services no longer duplicate the loader.

Drop the Arc from the liveness public API

  • liveness::spawn and Runtime::create now take the liveness client by value (LivenessClient + Clone + 'static) instead of Arc<LivenessClientType>. The real GrpcLivenessClient is already a cheap, Arc-backed clone (it wraps a ConnectionPool), so the outer Arc was redundant; the binary now passes the client directly.
  • Adds a blanket impl<LivenessClientType: LivenessClient + ?Sized> LivenessClient for Arc<LivenessClientType> that forwards through the shared pointer, so callers who genuinely want shared ownership — such as the actor unit tests that retain a handle to inspect the mock — keep working with no changes. Arc is now opt-in rather than mandated.

Notes

Config requires host to be set explicitly; an earlier draft auto-detected the local IP routed toward storage, but that was dropped in favor of taking the advertised IP from config.

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

  • Ensure all workflows pass.

Warning

The binary is not tested with storage/scheduler endpoints yet since the required services are not fully implemented.

Summary by CodeRabbit

  • New Features
    • Added a CLI entrypoint for the execution manager that loads settings from a YAML config, initializes logging, connects to required services, and supports clean Ctrl-C shutdown.
    • Introduced shared YAML-backed configuration loading and gRPC endpoint helpers for service settings.
  • Bug Fixes
    • Updated storage/server configuration to remove YAML-loading functionality and stop exporting the associated configuration error type.

@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners June 28, 2026 21:21
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e3563876-0eb8-4775-b7a2-4265315e0350

📥 Commits

Reviewing files that changed from the base of the PR and between d644646 and e25bf26.

📒 Files selected for processing (1)
  • components/spider-execution-manager/src/config.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/spider-execution-manager/src/config.rs

Walkthrough

Adds shared YAML config helpers, migrates storage off its local loader, introduces execution-manager config types, refactors liveness/runtime client ownership, and adds a new execution-manager CLI binary.

Changes

Shared config utilities and storage migration

Layer / File(s) Summary
Shared config helpers and storage migration
components/spider-utils/Cargo.toml, components/spider-utils/src/lib.rs, components/spider-utils/src/config.rs, components/spider-storage/Cargo.toml, components/spider-storage/src/config.rs, components/spider-storage/src/lib.rs, components/spider-storage/src/bin/grpc_server.rs
Adds yaml_serde, pub mod config, ConfigError, YamlConfig, and EndpointConfig in spider-utils; removes yaml_serde, ServerConfig::from_yaml_file, and ConfigError from spider-storage, and updates grpc_server.rs to import YamlConfig.

Execution manager config, runtime refactor, and binary

Layer / File(s) Summary
Execution manager config model
components/spider-execution-manager/src/config.rs, components/spider-execution-manager/src/lib.rs
Adds Config, LivenessConfig, and TaskExecutorConfig, derives RuntimeConfig, and re-exports the config module at the crate root.
Liveness client ownership and runtime API
components/spider-execution-manager/src/client/liveness.rs, components/spider-execution-manager/src/liveness.rs, components/spider-execution-manager/src/runtime.rs
Adds Arc<T> forwarding for LivenessClient, changes liveness/runtime APIs to accept clonable clients by value, and adds Runtime::get_em_id().
Execution manager CLI binary
components/spider-execution-manager/Cargo.toml, components/spider-execution-manager/src/bin/execution_manager.rs
Adds the binary target and CLI dependencies, then implements the entrypoint that loads config, connects clients, creates the runtime, and handles shutdown with tokio::select!.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • y-scope/spider#327: Introduced execution-manager client traits that this PR extends with Arc<T> forwarding and updated bounds.
  • y-scope/spider#340: Added the gRPC liveness client wiring that fits the updated Runtime::create and LivenessClient ownership model here.
  • y-scope/spider#360: Also changes execution-manager gRPC client construction and runtime wiring around pool-backed connections.

Suggested reviewers

  • sitaowang1998
🚥 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 change: adding the spider execution manager binary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

@LinZhihao-723 LinZhihao-723 changed the title # feat(spider-execution-manager): Add the execution-manager binary. feat(spider-execution-manager): Add the execution-manager binary. Jun 28, 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.

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (1)
components/spider-storage/src/config.rs (1)

24-26: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Keep the old config-loading surface or update the binary call site

components/spider-storage/src/bin/grpc_server.rs still calls ServerConfig::from_yaml_file(...), so removing that API here breaks the existing binary. A small forwarding shim/re-export would preserve compatibility for now.

🤖 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 `@components/spider-storage/src/config.rs` around lines 24 - 26, The
config-loading API removal breaks the existing grpc server call site, so restore
compatibility by keeping a forwarding shim or re-export on ServerConfig. Update
or add the config-loading method in DatabaseConfig/ServerConfig so
grpc_server.rs can still call ServerConfig::from_yaml_file(...) without changes,
or adjust that binary to use the new loading surface consistently.
🤖 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 `@components/spider-execution-manager/src/bin/execution_manager.rs`:
- Around line 65-72: The ctrl_c handling in execution_manager::main treats
listener setup failures like a normal shutdown, which is incorrect. Update the
tokio::select! branch for tokio::signal::ctrl_c() so that an Err from ctrl_c()
is returned immediately as a startup failure after logging, and only log
“Received Ctrl-C” plus call cancellation_token.cancel() when the signal listener
succeeds with Ok(()). Keep the fix localized to the ctrl_c branch and the
surrounding run_handle.await flow.

In `@components/spider-execution-manager/src/config.rs`:
- Around line 56-61: Reject zero heartbeat intervals in LivenessConfig by
changing the storage_heartbeat_interval_sec and scheduler_heartbeat_interval_sec
fields to a non-zero type such as NonZeroU64 so invalid YAML cannot deserialize
to 0. Update RuntimeConfig construction to read these values with .get() before
creating Durations, and keep the fix localized around LivenessConfig and
RuntimeConfig.

In `@components/spider-utils/src/config.rs`:
- Around line 50-79: `EndpointConfig` currently uses `IpAddr`, which is fine for
binding but too restrictive for dialing gRPC targets that may be hostnames.
Update the config so the client-facing endpoint construction in
`EndpointConfig::endpoint` can accept DNS names/authority values instead of only
IPs, or split the bind and dial settings into separate types. Keep `socket_addr`
only for bind use cases, and adjust deserialization/validation around `host` so
`scheduler.default.svc.cluster.local`-style targets can be represented.

---

Outside diff comments:
In `@components/spider-storage/src/config.rs`:
- Around line 24-26: The config-loading API removal breaks the existing grpc
server call site, so restore compatibility by keeping a forwarding shim or
re-export on ServerConfig. Update or add the config-loading method in
DatabaseConfig/ServerConfig so grpc_server.rs can still call
ServerConfig::from_yaml_file(...) without changes, or adjust that binary to use
the new loading surface consistently.
🪄 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: 659c0830-f9d9-43e3-8b42-6aacb2c3bee5

📥 Commits

Reviewing files that changed from the base of the PR and between 76a7adc and d644646.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • components/spider-execution-manager/Cargo.toml
  • components/spider-execution-manager/src/bin/execution_manager.rs
  • components/spider-execution-manager/src/client/liveness.rs
  • components/spider-execution-manager/src/config.rs
  • components/spider-execution-manager/src/lib.rs
  • components/spider-execution-manager/src/liveness.rs
  • components/spider-execution-manager/src/runtime.rs
  • components/spider-storage/Cargo.toml
  • components/spider-storage/src/bin/grpc_server.rs
  • components/spider-storage/src/config.rs
  • components/spider-storage/src/lib.rs
  • components/spider-utils/Cargo.toml
  • components/spider-utils/src/config.rs
  • components/spider-utils/src/lib.rs
💤 Files with no reviewable changes (1)
  • components/spider-storage/Cargo.toml

Comment thread components/spider-execution-manager/src/bin/execution_manager.rs
Comment thread components/spider-execution-manager/src/config.rs Outdated
Comment thread components/spider-utils/src/config.rs
@sitaowang1998
sitaowang1998 merged commit c0fe56f into y-scope:main Jun 28, 2026
13 checks passed
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.

2 participants