feat: add implementation for ack environmeent #1424
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.47) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 496 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.371
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1424"
general
weight: 0.35
KunWuLuan
Summary
This PR adds a new ACKEnvironment implementation for Harbor sandboxes, enabling integration with Alibaba Cloud Container Service for Kubernetes (ACK). The implementation provides a
flexible and production-ready way to run Harbor workloads on Kubernetes clusters.
Key Features
1. Kubernetes Client Management
- Singleton KubernetesClientManager ensures efficient client sharing across all environment instances
- Automatic cleanup at program termination via atexit hooks
- Support for both kubeconfig-based and in-cluster authentication
- Reference counting for proper resource management
2. Two Deployment Modes
Standard Pod Mode:
- Build images locally and push to container registry
- Support for Docker-in-Docker (DinD) and BuildKit image building
- Automatic image existence checking with fallback to building
- Configurable resource requests/limits, node selectors, tolerations
SandboxClaim Mode (OpenKruise Integration):
- Uses OpenKruise SandboxClaim to obtain pre-warmed sandboxes from a SandboxSet pool
- Eliminates cold start latency by maintaining warm container pools
- Configurable pool size (sandboxset_replicas), claim timeout, and environment injection
- Automatic SandboxSet creation and management
3. Resource Management
- CPU, memory, and ephemeral storage resource configuration
- Optional memory limit multiplier
- Service account and image pull secret support
- Node selector and tolerations for scheduling control
4. SWE-Agent Fixes
- Added --clear flag to uv venv command to handle existing venv conflicts
- Fixed shell variable expansion for CONDA_DEFAULT_ENV using ${VAR:-} syntax
- Added support for passing OPENAI_API_KEY to SWE-agent configuration
Files Changed
``
┌──────────────────────────────────────────┬─────────────────────────────────────────────────┐
``│ File │ Changes │
├──────────────────────────────────────────┼─────────────────────────────────────────────────┤
│ src/harbor/environments/ack.py │ New ACKEnvironment implementation (~2000 lines) │
├──────────────────────────────────────────┼─────────────────────────────────────────────────┤
│ src/harbor/models/environment_type.py │ Added ACK environment type enum │
├──────────────────────────────────────────┼─────────────────────────────────────────────────┤
│ src/harbor/environments/factory.py │ Registered ACKEnvironment in factory │
├──────────────────────────────────────────┼─────────────────────────────────────────────────┤
│ src/harbor/agents/installed/swe_agent.py │ Minor fixes for venv and API key handling │
├──────────────────────────────────────────┼─────────────────────────────────────────────────┤
│ .gitignore │ Updated to ignore additional files │
└──────────────────────────────────────────┴─────────────────────────────────────────────────┘
Configuration Example
environment:
type: ack
namespace: harbor-sandbox
registry: registry.cn-hangzhou.aliyuncs.com/my-org
use_sandbox_claim: true
sandbox_image: python:3.12
sandboxset_replicas: 5
claim_timeout: 300
Testing
Tested on ACK clusters with both standard Pod mode and SandboxClaim mode.
References
- Alibaba Cloud ACK Documentation
- OpenKruise SandboxClaim
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/1424" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin">
</picture>
</a>
<!-- devin-review-badge-end -->