Skip to content

feat: add Alibaba Function Compute serverless runtime provider support#643

Open
insight-bit wants to merge 12 commits intoalibaba:masterfrom
insight-bit:fc3-feature
Open

feat: add Alibaba Function Compute serverless runtime provider support#643
insight-bit wants to merge 12 commits intoalibaba:masterfrom
insight-bit:fc3-feature

Conversation

@insight-bit
Copy link

@insight-bit insight-bit commented Mar 16, 2026

resolves #644

Summary

  • Add Alibaba Cloud Function Compute 3.0 (FC3) as sandbox runtime provider
  • Support three deployment modes: Custom Runtime, Custom Container, Hybrid Adapter
  • Implement thread-safe CircuitBreaker for fault tolerance
  • Add WebSocket reconnection and retry mechanisms
  • Add path traversal protection in server
  • Support session affinity configuration (HEADER_FIELD mode)
  • Comprehensive test coverage (126 tests)

Key Components

FC3 Client (rock/deployments/fc3.py)

  • FC3Sandbox: Main sandbox client with session management
  • CircuitBreaker: Thread-safe fault tolerance with OPEN/CLOSED/HALF_OPEN states
  • WebSocket reconnection with exponential backoff retry
  • Custom exceptions: FC3Error, FC3SandboxNotFoundError, FC3RuntimeError

FC3 Rocklet (rock/deployments/fc3_rocklet/)

  • runtime/: Custom Runtime bootstrap and configuration
  • container/: Custom Container Dockerfile and configuration
  • adapter/: Hybrid Adapter HTTP/WebSocket server with path traversal protection

Tests

  • test_fc3_deployment.py: Client tests (48 tests)
  • test_fc3_rocklet_adapter.py: Adapter endpoint tests (29 tests)
  • test_fc3_rocklet_runtimes.py: Runtime config validation tests (49 tests)

Test Plan

  • Unit tests pass: pytest tests/integration/deployments/test_fc3_*.py -v
  • All 126 tests passing
  • Path traversal security tests
  • CircuitBreaker thread-safety tests
  • WebSocket reconnection tests

🤖 Generated with Claude Code

@CLAassistant
Copy link

CLAassistant commented Mar 16, 2026

CLA assistant check
All committers have signed the CLA.

@insight-bit insight-bit changed the title feat: add Alibaba FC3 serverless runtime provider support feat: add Alibaba Function Compute serverless runtime provider support Mar 16, 2026
insight-bit and others added 6 commits March 17, 2026 00:05
Add comprehensive support for Alibaba Cloud Function Compute 3.0 (FC3)
as a sandbox runtime provider, enabling serverless deployment of ROCK
sandboxes with three deployment modes:

- Custom Runtime: Lightweight Python runtime with bootstrap script
- Custom Container: Full Docker container deployment
- Hybrid Adapter: HTTP/WebSocket adapter for FC3 function integration

Key components:
- FC3 client with thread-safe CircuitBreaker for fault tolerance
- WebSocket reconnection and retry mechanisms
- Path traversal protection in server
- Session affinity configuration (HEADER_FIELD mode)
- Comprehensive test coverage (78 tests)

Change-Id: Ic78b67b99949572ef75139bd3965b75b10a30a32
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add FC3DeploymentConfig class to rock/deployments/config.py to fix
ImportError in test_fc3_deployment.py. The config class provides:

- FC3 function configuration (name, region, memory, cpus)
- Authentication fields (account_id, access_key_id, access_key_secret)
- Session affinity and TTL settings
- get_deployment() method returning FC3Deployment instance

Change-Id: If5022e63f00d85d3746b3c6a75bf8a4d09cda7e3
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests to verify FC3DeploymentConfig can be imported from
rock.deployments.config module to prevent regression of the
ImportError issue.

- test_import_from_config_module: Verifies import works
- test_is_deployment_config_subclass: Verifies inheritance

Change-Id: I02292516eef42ec276bf76bc2476bfb77804e88d
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add security_token field to FC3DeploymentConfig for STS temporary credentials
- Fix TestSandboxManagerFC3Integration to test deployment factory instead of
  non-existent SandboxManager FC3 routing
- Fix test_config_missing_credentials to expect None defaults instead of empty strings

Change-Id: I4609cea9405a3ab6f8a2c17b2c48b6639ed9ff4f
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add _fc3_deployments dict to store FC3 deployment instances
- Add _fc3_deployments_lock for thread-safe access
- Add _is_fc3_sandbox() method to check if sandbox is FC3 type
- Add _start_fc3_sandbox() and _stop_fc3_sandbox() methods
- Update tests to use dict-based sandbox type detection
- Add skip conditions for tests requiring gem module

Change-Id: Ie870d278e6a3ff0aa7d59f4f9bd22acbb1881b0f
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change-Id: Ic205ab5b0fa7f43774e1b642ecef9dbcda74a92e
Co-developed-by: Claude <noreply@anthropic.com>
- Rename fc3.py to fc.py, FC3Deployment to FCDeployment
- Rename fc3_rocklet/ to fc_rocklet/
- Update all FC3/FC3 references to FC in comments and strings
- Remove FC3DeploymentConfig backward compatibility alias
- Remove auto_clear_time property (use sandbox_ttl directly)
- Fix async methods in tests (is_session_alive, get_session_stats)
- Update test fixtures to include region and function_name

FC (Function Compute) is Alibaba Cloud serverless compute service.
The naming is simplified from FC3 to FC for clarity.

Change-Id: I4053ac81b47f818cd8644a013857e99415fb9168
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
insight-bit and others added 5 commits March 17, 2026 13:49
- Rename sandbox_ttl → session_ttl (FC session lifetime)
- Rename sandbox_idle_timeout → session_idle_timeout (FC session idle timeout)
- Rename timeout → function_timeout (FC function execution timeout)
- Update docstrings to use FC-native session terminology
- Fix sandbox_manager.py to use new field names
- Update tests to match new field names

The FC layer uses "session" as its native concept, while "sandbox"
is a ROCK abstraction. This change aligns the FC configuration with
FC-native terminology for better clarity.

Change-Id: Idc4d12c354a83d1cc95354d2de677f941c2ff3a5
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename function_name from rock-rocklet-rt/rock-rocklet-adapter/rock-rocklet
  to unified "rock-serverless-runtime-rocklet" across all deployment modes
- Update FCConfig default function_name
- Update rock-fc.yml configuration
- Update all s.yaml files (runtime/adapter/container)

The three deployment modes are examples; production only needs one.
Using a unified function_name simplifies configuration management.

Change-Id: I3b862a369e866ef1ab94aea304ae08f134eae894
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change-Id: Ica8c58c41eada8348d0ec045ade012c1ba22aedd
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add pytest-based E2E tests (test_fc_e2e.py) covering:
  - FC SDK protocol (health check, session lifecycle, command execution)
  - HTTP protocol (all rocklet endpoints)
  - WebSocket session operations
  - Error handling

- Add shell script (run_e2e_http_tests.sh) for manual E2E testing:
  - Auto-detect FC URL from 's info' command
  - Support FC_URL environment variable override
  - Avoid pipe-based URL extraction for better resource handling

- Fix /execute endpoint: add 'shell: true' to command requests
  to properly interpret shell command strings instead of treating
  them as executable paths

Change-Id: I5df7887919c13fd58bbf8bbb5d58912c5bba7971
Co-developed-by: Claude <noreply@anthropic.com>
- Add 'need_fc' pytest marker and CI test step
- Fix adapter execute(): add shell=True for proper command interpretation
- Fix adapter route_request(): accept both 'session_id' and 'session' params
- Add logConfig: auto to s.yaml for automatic SLS project creation
- Update README with credential configuration instructions
- Rename output files from fc3_rocklet to fc_rocklet for consistency

Change-Id: Id918ca900a9a449a5499d2fe796543aaf0b0144a
Co-developed-by: Claude <noreply@anthropic.com>
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.

feat: support Alibaba Function Compute as sandbox runtime provider

2 participants