Skip to content

feat(sandbox): enforce container rootfs disk limit via Docker storage-opt#654

Open
zhangjaycee wants to merge 3 commits intoalibaba:masterfrom
zhangjaycee:feature/disk_limit
Open

feat(sandbox): enforce container rootfs disk limit via Docker storage-opt#654
zhangjaycee wants to merge 3 commits intoalibaba:masterfrom
zhangjaycee:feature/disk_limit

Conversation

@zhangjaycee
Copy link
Copy Markdown
Collaborator

@zhangjaycee zhangjaycee commented Mar 23, 2026

close #653

@zhangjaycee zhangjaycee changed the title feat(sandbox): enforce container rootfs disk limit via Docker storage… feat(sandbox): enforce container rootfs disk limit via Docker storage-opt Mar 23, 2026
…ction

- detect_storage_opt_support(): checks overlay2 driver + xfs backing + prjquota mount option
- get_docker_info() / get_docker_root_dir(): thin wrappers around docker info
- is_xfs_path(): checks if a filesystem path lives on an XFS mount

These utilities are consumed by DockerDeployment to decide whether to apply
--storage-opt and xfs_quota at container start time.
Rootfs quota (storage-opt):
- Add limit_disk field to DockerDeploymentConfig; default None (no limit).
- Pass --storage-opt size=<limit_disk> to docker run when the field is set.
- Graceful degradation: if the worker does not support storage-opt
  (requires overlay2 + xfs + prjquota), effective_limit_disk is set to None
  while config.limit_disk stays unchanged.
- Surface effective_limit_disk in SandboxInfo, sandbox_actor status, and
  SandboxStatusResponse so callers can observe the applied quota.

Log-dir quota (XFS project quota):
- Add limit_log_dir field to DockerDeploymentConfig; default None (no limit).
- After container start, call xfs_quota to assign a per-project hard limit
  on ROCK_LOGGING_PATH; skip silently when the path is not on XFS.

Server-side configuration:
- RuntimeConfig gains default_limit_disk and default_log_dir_quota (both
  default to None); set in rock-xxx.yml per environment.
- _apply_disk_limits() in sandbox_api reads these values and then checks
  Nacos for runtime overrides (Nacos wins over yml; None in both = no limit).
- Remove limit_disk from SandboxStartRequest / SandboxConfig (SDK) — quota
  policy is server-side only; clients observe it via status responses.
Unit tests:
- test_docker_util.py: detect_storage_opt_support, is_xfs_path, get_docker_root_dir
- test_docker_deployment_disk_limit.py: _storage_opts(), start() degradation,
  effective_limit_disk vs config.limit_disk invariants
- test_sandbox_manager_disk_limit.py: validate limit_disk format
- test_sandbox_response.py: limit_disk field in SandboxStatusResponse

Integration tests:
- test_disk_limit_enforcement: rootfs quota blocks oversized files (SKIP_IF_NO_STORAGE_OPT)
- test_disk_limit_default_value: server-reported limit_disk reflects configured value
- test_logging_path_disk_limit_enforcement: log-dir quota is independently enforced
  (SKIP_IF_NO_STORAGE_OPT + SKIP_IF_LOG_PATH_NOT_XFS)
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 sandbox disk space limitation

1 participant