Skip to content

fix(server,docs): reject gVisor + networkPolicy and document egress sidecar incompatibility#1070

Open
Pangjiping wants to merge 2 commits into
mainfrom
fix/gvisor-egress-compat-934
Open

fix(server,docs): reject gVisor + networkPolicy and document egress sidecar incompatibility#1070
Pangjiping wants to merge 2 commits into
mainfrom
fix/gvisor-egress-compat-934

Conversation

@Pangjiping

Copy link
Copy Markdown
Collaborator

Summary

Closes #934

  • Add ensure_egress_runtime_compatible() validator that returns HTTP 400 when networkPolicy is requested under secure_runtime.type=gvisor (gVisor lacks iptables nat table required by the egress sidecar's DNS redirect)
  • Wire validation into both K8s and Docker _ensure_network_policy_support() paths
  • Log startup warning when gVisor + egress image configured together
  • Add iptables nat table (egress sidecar) row to compatibility matrix in docs/secure-container.md
  • Add troubleshooting entry for egress sidecar + gVisor CrashLoopBackOff
  • Add "Runtime Compatibility" section to docs/network-isolation-for-kubernetes.md
  • Add gVisor + egress e2e test case (skips when EGRESS_IMG not set)

Test plan

  • uv run pytest tests/ — 1145 passed
  • ruff check — all checks passed
  • E2E: EGRESS_IMG=opensandbox/egress:v1.0.12 go test ./test/e2e_runtime/gvisor/... on a gVisor-enabled cluster

🤖 Generated with Claude Code

…idecar incompatibility (#934)

gVisor's netstack does not implement the iptables nat table, which the
egress sidecar requires for DNS redirect. This caused silent
CrashLoopBackOff when operators combined secure_runtime.type=gvisor
with network_policy.

- Add ensure_egress_runtime_compatible() validator that returns HTTP 400
  when networkPolicy is requested under gVisor runtime
- Wire validation into both K8s and Docker _ensure_network_policy_support()
- Log startup warning when gVisor is configured alongside egress image
- Add iptables nat row to compatibility matrix in docs/secure-container.md
- Add troubleshooting entry for egress sidecar + gVisor failure
- Add runtime compatibility section to docs/network-isolation-for-kubernetes.md
- Add gVisor + egress e2e test case in kubernetes/test/e2e_runtime/gvisor/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Pangjiping Pangjiping added bug Something isn't working documentation Improvements or additions to documentation component/server labels Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc8bf3ab1b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

and that the secure runtime supports the iptables nat table needed by the sidecar.
"""
ensure_egress_configured(request.network_policy, self.app_config.egress)
ensure_egress_runtime_compatible(request.network_policy, self.app_config.secure_runtime)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate template-provided RuntimeClasses

When Kubernetes users set runtimeClassName: gvisor through kubernetes.batchsandbox_template_file or agent_sandbox.template_file instead of [secure_runtime], this check still receives secure_runtime=None and allows networkPolicy. The providers later merge the runtime manifest into the base template, preserving a template runtimeClassName when the runtime pod spec does not override it, so the egress sidecar can still be created under gVisor and hit the CrashLoop this patch is intended to prevent. Please validate the effective RuntimeClass, including template-supplied values, before accepting the request.

Useful? React with 👍 / 👎.

…r+egress check

Template-provided runtimeClassName bypassed the gVisor+egress validation
because the check ran against secure_runtime config before the template
merge. Now validate the assembled pod spec's runtimeClassName in each
provider after merge_with_runtime_values, catching gVisor regardless of
whether it came from config or template.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c50d35f74b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

runtime_type = effective_runtime_class
if not runtime_type:
return
if runtime_type in _GVISOR_NAT_INCOMPATIBLE_RUNTIMES:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve RuntimeClass handlers instead of matching names

When the runtime comes from a template, effective_runtime_class is only the RuntimeClass object's name, but this rejects only the literal name gvisor. RuntimeClass names are deployment-defined while the handler identifies gVisor/runsc, so a template using a custom name such as runsc or gvisor-secure with handler runsc will still receive the egress sidecar and hit the gVisor CrashLoop this patch is meant to prevent. Please resolve the RuntimeClass handler or carry runtime type metadata for template-supplied classes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component/server documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the egress sidecar work under runtimeClassName: gvisor (or document the incompatibility)

1 participant