Skip to content

fix(networking): harden webhook policy assumptions - #4058

Merged
Aleksei Sviridkin (lexfrei) merged 4 commits into
mainfrom
fix/3997-webhook-policy-followups
Oct 7, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 4 commits into
mainfrom
fix/3997-webhook-policy-followups

Conversation

@myasnikovdaniil

@myasnikovdaniil myasnikovdaniil commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

This is follow-up for #3997. It reads ingress-nginx admission port from effective subchart values and refuses empty value, and fixes kubeProxyReplacement=false status because cozystack has no supported Service translator in that state. Gateway test now requires one real ClusterIP and keeps same ready Pod UID, IP and port for whole probe, so stale EndpointSlice, replaced Pod or wrong Service can't report deny. Policy selectors and two-ended deny from #3997 stay unchanged, and this does not claim root cause for #3983.

Screenshots

Not applicable.

Downstream repositories

Release note

fix(networking): use effective ingress admission port, report unsupported Cilium service routing correctly, and reject stale backend evidence in gateway tests

Summary by CodeRabbit

  • Bug Fixes

    • Admission webhook connectivity checks now validate the configured Service and its exact backend endpoint throughout probing, improving failure detection.
    • Admission webhook policies now fail closed when the webhook port is not explicitly configured.
  • Documentation

    • Clarified that supported service routing requires kubeProxyReplacement: true.
    • Updated guidance to explain that disabling this setting or webhook policies does not provide a supported fallback.
  • Tests

    • Added coverage for missing webhook port configuration and strengthened networking stability checks.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: cozystack/cozystack/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fffca5a2-a7f0-4e26-8a20-71c5e88f8746
📥 Commits

Reviewing files that changed from the base of the PR and between 69dd1a0 and fd0a0fa.

📒 Files selected for processing (3)
  • hack/e2e-chainsaw/gateway/chainsaw-test.yaml
  • packages/system/cilium/values.yaml
  • packages/system/ingress-nginx/values.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/system/ingress-nginx/values.yaml
  • packages/system/cilium/values.yaml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The changes describe kubeProxyReplacement: true as required for supported ClusterIP routing, require an explicit admission webhook port, and strengthen admission backend validation before, during, and after the probe.

Changes

Webhook routing and validation

Layer / File(s) Summary
Cilium service-routing invariant
packages/system/cilium/..., packages/apps/kubernetes/...
Beacon messages, HelmRelease text, values comments, and tests describe kubeProxyReplacement: false as unsupported for ClusterIP routing.
Admission webhook policy contract
packages/system/ingress-nginx/...
The policy reads the webhook port from subchart values and fails when the port is unset. Documentation and tests describe supported service translation and target-side denial.
Kube-OVN webhook policy alignment
packages/system/kubeovn-webhook/...
Policy comments describe the supported kube-ovn topology. The Makefile adds a Helm unit-test target.
Exact admission backend probing
hack/e2e-chainsaw/gateway/chainsaw-test.yaml
The test uniquely discovers Services, selects a complete ready backend, probes the admission ClusterIP, and rechecks the backend and controller readiness around the probe.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ChainsawTest
  participant AdmissionService
  participant EndpointSlices
  participant ControllerPod
  ChainsawTest->>AdmissionService: Discover ClusterIP and named ports
  ChainsawTest->>EndpointSlices: Select a ready backend
  ChainsawTest->>ControllerPod: Check backend identity and restart state
  ChainsawTest->>AdmissionService: Probe the ClusterIP
  ChainsawTest->>EndpointSlices: Recheck the selected backend
  ChainsawTest->>ControllerPod: Recheck controller readiness
Loading

Merge Risk: ⚪ Minimal · up to fd0a0

This change clarifies the supported Cilium routing requirement, requires an explicit admission webhook port, and tightens the gateway admission test. No actionable merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly relates to the networking changes and summarizes the effort to harden webhook policy assumptions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/XL This PR changes 500-999 lines, ignoring generated files area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug labels Sep 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

myasnikovdaniil LGTM. The corrected kubeProxyReplacement=false story matches the tree, and the tighter gateway probe closes the stale-evidence gaps it targets.

I checked the new claim against the topology. kubeovn/values.yaml sets ENABLE_LB: false, the documented installs disable kube-proxy, and the Kamaji control plane in apps/kubernetes ships only the konnectivity addon. So with the value off there is nothing left to translate a ClusterIP, and the old "webhook reopens" wording described a path that doesn't exist. The probe now reads the admission port by name, and the vendored chart does call it https-webhook on both the Service and its EndpointSlice. E2E Tests passed on this head on 2026-09-03 (attempt 1).

On a trial merge with current main, the helm suites for cilium, ingress-nginx, kubeovn-webhook and apps/kubernetes all pass. Dropping the new required and going back to dig "port" 8443 turns the new ingress-nginx case red.

One small thing about the description, not blocking. Reading the port from the parent's .Values["ingress-nginx"] again, with required kept, still passes all 24 tests. That's because Helm already merges subchart defaults into the parent's view of that key, so main was reading the effective port too, and the .Subcharts switch is a cleanup. The real fix is the fail-closed required. The PR body and the first commit say the port source changed, so you may want to reword that before merge, since the body becomes the merge commit message.

Read the ingress admission port from the effective subchart values and fail if the port is absent. Describe kube-proxy replacement as a required service-routing invariant while retaining target-side enforcement.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>
Probe one exact ready admission EndpointSlice backend throughout the measurement window and reject missing or ambiguous Service ports. Ensure the kubeovn-webhook Helm suites run through package discovery.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>
Limit the fail-open discussion to the actual counterexample: another component translating the Service after Cilium source-side egress policy. A disabled translator by itself leaves no working Service path.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>
Require a real admission ClusterIP and carry the EndpointSlice target UID into the direct-backend coordinate. Tie that coordinate to a non-empty current Pod snapshot so stale endpoints or masked list failures cannot produce a policy verdict.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

myasnikovdaniil I rebased this onto current main.

@github-actions github-actions Bot added the area/networking Issues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn) label Oct 7, 2026
@lexfrei
Aleksei Sviridkin (lexfrei) merged commit 5486d4f into main Oct 7, 2026
24 of 37 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the fix/3997-webhook-policy-followups branch October 7, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking Issues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn) area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug size/XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants