Skip to content

feat: support sandbox network policies with YuanRong 0.9.7 - #22

Merged
tianyuzhou95 merged 5 commits into
inclusionAI:mainfrom
WenYuLuo:pr20-openyuanrong-0.9.5
Aug 13, 2026
Merged

feat: support sandbox network policies with YuanRong 0.9.7#22
tianyuzhou95 merged 5 commits into
inclusionAI:mainfrom
WenYuLuo:pr20-openyuanrong-0.9.5

Conversation

@WenYuLuo

@WenYuLuo WenYuLuo commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds creation-time sandbox network policies to the public Python SDK and coordinates the openYuanRong 0.9.7 and sandboxd runtime changes required to enforce them.

from akernel_sdk import NetworkPolicy, Sandbox

Sandbox()  # unrestricted
Sandbox(network_policy=NetworkPolicy.block())
Sandbox(network_policy=NetworkPolicy.deny_dns("github.com", "*.github.com"))

NetworkPolicy.block() installs a stateful IPv4 default-deny policy for new flows while preserving YuanRong control and published sandbox-port routes used by direct filesystem I/O, reverse tunnels, and explicit port forwarding. DNS policies deny normalized exact or leading-wildcard names without installing a general packet allowlist.

Scope

Dependencies

  • Pin openyuanrong-sandbox==0.9.7, optional openyuanrong-sdk==0.9.7, and openYuanRong tag commit 9229bbb4a0d129d10dd6aed6099f64f8fda8cf9d.
  • Pin sandboxd upstream main commit 17b78468a5454ecb86b15ca0bc4f3461cb95f06a.
  • Refresh the published 0.9.7 RRT and AMD64/ARM64 core-wheel checksums.

SDK and compatibility

  • Add the backend-independent NetworkPolicy API and translate it through both YuanRong backends.
  • Use the native local-only lifecycle close after stable-ID termination.
  • Preserve deployment-configured runtime rootfs overlays for runtime-only requests.
  • Forward custom reverse-tunnel ports and retain command, filesystem, tunnel, and port-forward control paths under block mode.

Deployment

  • Enable sandbox ACL support in Helm, Terraform, and standalone configurations.
  • Keep host kernel-module loading in node provisioning: Terraform node bootstrap and standalone host startup load br_netfilter; the node container validates the prerequisite and configures namespace-local bridge netfilter.
  • Document separate iptables and bpfnat host requirements and the drained-node upgrade requirement.
  • Publish standalone dynamic routes through the FunctionMaster HTTP provider so reverse tunnels remain reachable.
  • Preserve the configured etcd StatefulSet service identity during in-place Helm upgrades.

Validation

  • 109 Python SDK unit tests passed; Ruff and Mypy passed for all 21 SDK source files.
  • Deployment shell syntax and Helm lint passed.
  • GitHub Actions passed on Python 3.10, 3.11, 3.12, 3.13, and 3.14.
  • openYuanRong Buildkite #239 passed all 19 jobs for the ACL/RRT integration source.
  • Standalone validation passed unrestricted command, reverse-tunnel, and outbound HTTPS behavior. Under NetworkPolicy.block(), command and filesystem operations passed, the reverse tunnel returned AKERNEL_BLOCK_TUNNEL_OK, and unrelated outbound HTTPS timed out with exit code 124.
  • The cluster on Huawei CCE was upgraded to openYuanRong 0.9.7. Both nodes initialized the iptables ACL backend with bridge netfilter enabled and passed the same unrestricted/block-policy SDK validation.

Commit organization

The branch is rebased on the latest main and contains five self-contained commits:

  1. dependency/runtime pins;
  2. SDK network-policy API;
  3. resolution of the pre-existing lifecycle and custom-tunnel TODOs;
  4. deployment defaults, prerequisites, and routing;
  5. documentation.

Limitations

  • Policies are fixed at sandbox creation.
  • Packet policies currently cover IPv4.
  • DNS blacklist rules cover conventional UDP/TCP DNS, not DNS-over-HTTPS or direct known-IP connections.
  • block_network and dns_blacklist cannot be combined.

This PR supersedes #20.

@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch 2 times, most recently from ad97955 to 2ccc83d Compare August 10, 2026 08:57
@WenYuLuo
WenYuLuo marked this pull request as ready for review August 10, 2026 09:00
@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch 2 times, most recently from afec513 to 47cb268 Compare August 11, 2026 17:21

@tianyuzhou95 tianyuzhou95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK policy translation looks sound overall. I found one standalone startup blocker plus several backend-default and public-contract inconsistencies that should be addressed before merging.

Comment thread builder/scripts/sandboxd_network_prepare.sh Outdated
Comment thread builder/scripts/sandboxd_network_prepare.sh
Comment thread sdk/python/akernel_sdk/types.py Outdated
Comment thread deploy/README.md Outdated
Comment thread sdk/python/README.md Outdated
Comment thread README.md Outdated
@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch from c8dd238 to 4029916 Compare August 12, 2026 05:35
@WenYuLuo
WenYuLuo requested a review from tianyuzhou95 August 12, 2026 09:08
Comment thread builder/scripts/yr_node_bootstrap.sh
Comment thread deploy/akernel/charts/core/templates/node/daemonset.yaml Outdated
Comment thread deploy/akernel/charts/core/values.yaml
Comment thread deploy/standalone/start.sh
@tianyuzhou95

Copy link
Copy Markdown
Collaborator

Before the final review, could you please rebase this branch onto the latest main and reorganize the commit history by logical category? In particular, please fold the follow-up fixes into the corresponding dependency, SDK, deployment, and documentation commits so that each commit is self-contained and the final history clearly explains the changes.

Please also update the PR title and description to match the final scope of the implementation, including the coordinated openYuanRong and sandboxd dependency updates, SDK network-policy API, deployment prerequisites and defaults, tunnel/lifecycle compatibility changes, tests, and documentation. This will make the resulting change set easier to review and maintain.

@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch from 4029916 to 69fec0a Compare August 12, 2026 09:55
@WenYuLuo WenYuLuo changed the title feat(sdk): support sandbox network policies feat: support sandbox network policies with YuanRong 0.9.7 Aug 12, 2026
@WenYuLuo

Copy link
Copy Markdown
Contributor Author

Addressed the final-review request:

  • refreshed upstream/main; the branch was already 0 commits behind and is rebuilt directly on the latest main;
  • reorganized the history into four self-contained commits: dependency/runtime pins (b2e4142), SDK API and compatibility (3b78de3), deployment prerequisites/defaults/routing (00c7847), and documentation (69fec0a);
  • folded all follow-up fixes into those categories;
  • updated the PR title and description to cover the coordinated openYuanRong/sandboxd updates, SDK policy contract, deployment requirements, tunnel/lifecycle/rootfs compatibility, validation, and documentation.

The reorganized tree is byte-for-byte identical to the pre-reorganization tree plus the host-module ownership fix requested in this review.

WenYuLuo

This comment was marked as outdated.

@tianyuzhou95

Copy link
Copy Markdown
Collaborator

The rebase, logical commit grouping, and updated PR scope look good. I have two remaining presentation/metadata requests before the final review:

  1. Please wrap each commit body at approximately 72 characters, as required by the repository commit guidelines. The current four body paragraphs are each stored as a single long line (135, 201, 193, and 164 characters respectively). Please preserve the Conventional Commit titles, prose bodies, blank lines, and DCO sign-offs while rewrapping them.

  2. Please remove or generalize the specific test-environment identifier Huawei CCE cn-north-4/akernel-cce from the PR description. The validation result is useful, but it can be stated as validation on a managed Kubernetes cluster without publishing the region and cluster name.

No additional functional blocker was found in the updated change set.

Comment thread sdk/python/akernel_sdk/_backends/openyuanrong_sandbox.py
Comment thread sdk/python/akernel_sdk/sandbox.py Outdated
Comment thread sdk/python/akernel_sdk/types.py
Comment thread sdk/python/examples/network_policy.py Outdated
Comment thread sdk/python/tests/unit/test_backends.py Outdated
Pin openYuanRong 0.9.7 and the sandboxd network-ACL revision.
Refresh the matching Python packages, runtime artifacts, and checksums.

Signed-off-by: robbluo <luo1442@gmail.com>
@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch 2 times, most recently from f2e22c4 to 67496dd Compare August 13, 2026 03:11
Add unrestricted, stateful block-network, and DNS-deny policies to both
YuanRong backends. Preserve deployment-configured rootfs
configuration overrides. Cover the public contract with unit
tests.

Signed-off-by: robbluo <luo1442@gmail.com>
Use native local-only close after stable-ID termination. Forward custom
reverse-tunnel listener ports through proxy_port and enforce the
frontend adjacent WebSocket port contract.

Signed-off-by: robbluo <luo1442@gmail.com>
Enable ACLs in Helm, Terraform, and standalone deployments. Prepare host
and namespace prerequisites, preserve the legacy etcd service identity,
and publish standalone tunnel routes through FunctionMaster.

Signed-off-by: robbluo <luo1442@gmail.com>
@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch 3 times, most recently from 6cc5b6b to 7952cc9 Compare August 13, 2026 07:50
Describe the public stateful block-policy contract and backend-specific
host requirements. Cover standalone routing, the upgrade procedure,
limitations, and maintained examples.

Signed-off-by: robbluo <luo1442@gmail.com>
@WenYuLuo
WenYuLuo force-pushed the pr20-openyuanrong-0.9.5 branch from 7952cc9 to 4eed7be Compare August 13, 2026 07:53
@tianyuzhou95
tianyuzhou95 merged commit 1deb6b6 into inclusionAI:main Aug 13, 2026
6 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.

2 participants