Skip to content

feat(admin): add Template API for K8s Pool-based sandbox warm path - #1311

Merged
Generalwin merged 5 commits into
alibaba:masterfrom
Generalwin:e2b-style-template-implement
Aug 13, 2026
Merged

feat(admin): add Template API for K8s Pool-based sandbox warm path#1311
Generalwin merged 5 commits into
alibaba:masterfrom
Generalwin:e2b-style-template-implement

Conversation

@Generalwin

Copy link
Copy Markdown
Collaborator

What does this PR do?

Implements Template API for sandbox warm pool management via K8s Pool CRD. Resolves #1310.

Changes

  • Template API endpoints (template_api.py): POST/GET/DELETE /apis/envs/sandbox/v1/templates
  • K8s Provider (provider.py): Pool informer + create_template/get_template_status/delete_template methods
  • SandboxManager (sandbox_manager.py): proxy methods for template operations
  • Config (config.py): pool_template field for Jinja2-rendered Pool CRD config
  • Constants (constants.py): Pool CRD constants, TEMPLATE_ID_PREFIX = "tpl-", managed-by label
  • Proto (request.py/response.py): TemplateCreateRequest/TemplateStatusResponse

Design

  • templateID = tpl-{sha256(non-null spec fields)[:16]} — same spec always produces same ID
  • Pool CRD is the source of truth (no DB), Informer cache for reads
  • 409 Conflict on duplicate create = idempotent
  • Status mapping: available > 0 → ready, available == 0, total > 0 → building

Testing

  • Unit tests (tests/unit/test_template_api.py): 19 cases — ID generation, Spec, Jinja2 rendering, status mapping, constants
  • Smoke tests (tests/smoke/test_template.py): lifecycle (create → wait ready → delete) + idempotent create, with --admin-url and --smoke-image CLI options
pytest tests/unit/test_template_api.py     # 19 passed
pytest tests/smoke/ --smoke-image <image>  # 2 passed

@Generalwin
Generalwin force-pushed the e2b-style-template-implement branch from be4487a to 352ef98 Compare August 5, 2026 03:09
Comment thread rock/admin/entrypoints/template_api.py Outdated
Comment thread rock/sandbox/operator/k8s/template_loader.py
Comment thread rock/sandbox/operator/k8s/provider.py
@Generalwin
Generalwin force-pushed the e2b-style-template-implement branch from 4d65ac6 to a5f879b Compare August 10, 2026 03:15
@Generalwin
Generalwin requested a review from zhongwen666 August 10, 2026 03:17
@Generalwin
Generalwin merged commit a722eb8 into alibaba:master Aug 13, 2026
7 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.

[Feature] Template API: K8s Pool-based sandbox warm path

2 participants