Skip to content

feat(sdk): add ComposeJobConfig for multi-container docker-compose jobs (#1079)#1080

Open
xdlkc wants to merge 4 commits into
alibaba:masterfrom
xdlkc:feat/compose-job-config
Open

feat(sdk): add ComposeJobConfig for multi-container docker-compose jobs (#1079)#1080
xdlkc wants to merge 4 commits into
alibaba:masterfrom
xdlkc:feat/compose-job-config

Conversation

@xdlkc

@xdlkc xdlkc commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

What

Add ComposeJobConfig + ComposeTrial to run multi-container topologies (main + sidecars + init containers) inside a single DinD sandbox, orchestrated by a generated runner.sh via the docker CLI.

closes #1079

Design

  • Top-level compose block (peer of environment): keeps the two layers distinct — environment(SandboxConfig) describes the outer DinD sandbox, compose.* describes the inner containers.
  • Inherits BashJobConfig: top-level script_path is the main container entry; environment unchanged.
  • from_yaml detects the compose key (Harbor → Compose → Bash); existing Bash/Harbor YAML unaffected (all extra=forbid).

Data model (rock/sdk/job/compose/config.py)

ResourceSpec(cpus/memory + cpu_limit/memory_limit), VolumeMount(name/mount_path/main_mount_path/host_path), SecretEnvEntry, OssDep, HealthSpec, _ContainerBase(script/script_path/command/args/env/secret_env/resources/privileged), Init/Sidecar/MainContainerSpec, ComposeSpec, ComposeJobConfig (proxy-conflict + resource-budget validators).

Trial + runner.sh (rock/sdk/job/compose/trial.py)

7-phase runner.sh: start dockerd → oss deps → init (serial) → sidecars (detached, --network-alias) → health probe → main (foreground) → collect/cleanup. Secrets rendered as shell var refs (never literal); /rock/scripts bind-mounted into inner containers; all user values shlex-quoted.

End-to-end verified

Run on the real ROCK kata backend. Verified chain:

Job → kata sandbox → P0 dockerd → P3 proxy sidecar → P4 health ready
    → P5 main container (reuses outer dockerd) → harbor CLI running → dataset download

Fixed 4 issues only reproducible on the real backend:

  1. kata sandbox doesn't auto-start dockerd → runner.sh starts it
  2. nohup'd dockerd misses PATH → containerd not found → explicit PATH
  3. kata guest lacks br_netfilter → DOCKER_IGNORE_BR_NETFILTER_ERROR=1
  4. main.sh not found / 3rd-layer dockerd fails → /rock/scripts mount + reuse outer dockerd via mounted docker.sock

(Full harbor eval needs OSS dataset credentials, which are environment-specific.)

Tests

tests/unit/sdk/job/test_compose_config.py + test_trial_compose.py337 job unit tests pass (incl. Bash/Harbor regression), lint clean.

Examples

examples/job/compose/harbor_compose_demo.py (+ .env.example) — ready-to-run harbor demo, credentials via env vars.

🤖 Generated with Claude Code

Comment thread rock/sdk/job/compose/trial.py Outdated
# ── helpers ───────────────────────────────────────────────────────────────────


def _resource_args(res: ResourceSpec | None) -> list[str]:

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.

封装到类

@xdlkc xdlkc force-pushed the feat/compose-job-config branch from 8963236 to d69c3ef Compare June 15, 2026 03:33
xdlkc and others added 4 commits June 17, 2026 21:30
Implement ComposeJobConfig + ComposeTrial to run multi-container topologies
(main + sidecars + init containers) inside a single DinD sandbox, orchestrated
by a generated runner.sh via the docker CLI.

- config: ComposeSpec/MainContainerSpec/SidecarSpec/InitContainerSpec with
  resources(request/limit), command/args, privileged, secret_env, oss_deps,
  health probes, volume_mounts(host_path); from_yaml detects "compose" key
- trial: 7-phase runner.sh (dockerd start with kata fixes -> oss deps -> init
  -> sidecars -> health probe -> main -> collect/cleanup); secrets rendered as
  shell var refs; /rock/scripts bind-mounted into inner containers
- examples/job/compose: end-to-end harbor demo (verified against real backend
  up to harbor dataset download; only OSS creds missing)

End-to-end verified on ROCK kata backend: sandbox -> dockerd -> proxy sidecar
-> health ready -> main container -> harbor CLI running.

Co-Authored-By: Claude Code <noreply@anthropic.com>
AI-Model: claude-opus-4-8
AI-Contributed/Feature: 2477/2477
AI-Contributed/UT: 1233/1233
harbor_compose_demo.py + .env.example: env-var driven demo for running the
harbor task (claude-code / aone-bench-java100) via ComposeJobConfig, with all
real-backend fixes baked in. User only fills credentials (incl. OSS) to run.

Co-Authored-By: Claude Code <noreply@anthropic.com>
AI-Model: claude-opus-4-8
AI-Contributed/Feature: 240/240
AI-Contributed/UT: 0/0
…ompose.yaml)

Migrate from custom compose block with hand-written runner.sh orchestration
to standard docker-compose.yaml with native `docker compose up`. ROCK now
only bootstraps DinD dockerd and delegates all container orchestration to
compose, drastically reducing config surface and runner.sh complexity.

Co-Authored-By: Claude Code <noreply@anthropic.com>
AI-Model: claude-opus-4-6
AI-Contributed/Feature: 1791/1791
AI-Contributed/UT: 1342/1342
Co-Authored-By: Claude Code <noreply@anthropic.com>
AI-Model: claude-opus-4-6
AI-Contributed/Feature: 0/6
AI-Contributed/UT: 0/0
@xdlkc xdlkc force-pushed the feat/compose-job-config branch from d69c3ef to 0400514 Compare June 17, 2026 13:30
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.

[FEATURE] Support multi-container (Docker Compose) jobs via ComposeJobConfig

2 participants