← Back to Pull requests

feat: add implementation for ack environmeent #1424

Closed
unknown closed this pull request without merging on Jun 28, 2026 08:21 UTC
View on GitHub
unknown unknown commented on Apr 13, 2026 02:39 UTC
Author

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 -->

Diff: 496 lines (+372 / -124) across 6 files Reviewer: KunWuLuan Review duration: 109782m
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
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.5% (MEDIUM) · Higher = larger blast radius
47.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.5% · Safe to merge
20.5%