Skip to content

fix(gateway): copy allowed routes for the edge listener - #4167

Open
BingEdward (7487) wants to merge 1 commit into
cozystack:mainfrom
7487:fix/edge-listener-allowed-routes-aliasing
Open

BingEdward (7487) wants to merge 1 commit into
cozystack:mainfrom
7487:fix/edge-listener-allowed-routes-aliasing

Conversation

@7487

@7487 BingEdward (7487) commented Sep 8, 2026 •

Copy link
Copy Markdown

What this PR does

Fixes #4118. The edge listener retained the renderer's local edgeAllowedRoutes value, while edge-apex and child listeners already received independent copies. Give edge its own DeepCopy() as well, so later changes to the local value cannot reach the rendered listener. The rendered Gateway configuration is unchanged.

The change is confined to that one assignment. Current main already creates independent allowed-routes values for HTTPS and TLS-passthrough listeners.

Validation: go test ./internal/controller/tenantgateway -count=1 passes. No new test is added, as accepted in the maintainer's review.

Downstream repositories

The diff changes only ownership of a local allowed-routes value; API fields, namespace selectors, route kinds, package layout and rendered resources stay the same, so it reaches none of the downstream trigger map's contracts.

Release note

fix(gateway): give the edge TenantGateway listener its own allowed-routes copy; rendered Gateway configuration is unchanged

Summary by CodeRabbit

  • Bug Fixes
    • Fixed edge-mode gateway listeners so each retains its own allowed-routes configuration.

@coderabbitai

coderabbitai Bot commented Sep 8, 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: c606aa29-1a9c-433f-913d-c2f262e57ddb

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf56fb and f2ec6af.


📒 Files selected for processing (1)
  • internal/controller/tenantgateway/reconciler.go

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



📝 Walkthrough

Walkthrough

renderGateway now assigns the edge listener a deep copy of edgeAllowedRoutes instead of the shared value.

Changes

Edge listener AllowedRoutes

Layer / File(s) Summary
Edge listener route ownership
internal/controller/tenantgateway/reconciler.go
The edge listener receives a deep copy of edgeAllowedRoutes.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: lexfrei


Merge Risk: ⚪ Minimal · up to f2ec6

This change preserves the Gateway configuration while giving the edge listener its own AllowedRoutes copy. No actionable merge risk remains.

Pre-merge checks | Passed 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 and concisely describes the main change: copying allowed routes for the edge listener.
Linked Issues check Passed Issue #4118 requires each CertModeEdge listener to receive its own AllowedRoutes copy. The PR changes the edge listener assignment to edgeAllowedRoutes.DeepCopy(). The existing edge-apex and…
Out of Scope Changes check Passed The whole-PR summary reports one assignment change in internal/controller/tenantgateway/reconciler.go. The change only separates ownership of the AllowedRoutes value. It does not change rendered c…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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/L This PR changes 100-499 lines, ignoring generated files area/networking Issues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn) kind/cleanup Categorizes issue or PR as related to cleanup of code, process, or technical debt labels Sep 8, 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.

BingEdward (@7487) NOT LGTM: main moved under this branch, and most of what it fixes is already fixed there. The branch now conflicts in reconciler.go and reconciler_test.go.

#3342 (merged 2026-09-11) reworked renderGateway. On current main (f6a615f) port443Kinds is a constructor function, every https, https-apex and child listener gets httpsAllowedRoutes.DeepCopy(), and each tls-<svc> listener gets its own allowedRoutes.DeepCopy() with fresh kinds. The sharing you describe in the dns01/existingSecret and passthrough paths is gone.

What is still left is exactly the case #4118 reports: the edge listener at reconciler.go:1546 still takes edgeAllowedRoutes itself, while edge-apex and the children get a copy. So after a rebase the fix is AllowedRoutes: edgeAllowedRoutes.DeepCopy() on that one listener. A new listenerAllowedRoutes helper and a rewrite of every call site are no longer needed for that. I would take the one-line change without a new test, since nothing observable changes. If you want to keep the aliasing test, trim it to the edge mode.

I also checked the part that matters most in this file. listenerAllowedRoutes keeps base.Namespaces as is and only swaps the kinds, so this branch does not widen which namespaces can attach routes to any listener.

@7487 BingEdward (7487) changed the title refactor(gateway): give every Gateway listener its own allowedRoutes fix(gateway): copy allowed routes for the edge listener Oct 8, 2026
@7487
BingEdward (7487) force-pushed the fix/edge-listener-allowed-routes-aliasing branch from 9902778 to 7cf56fb Compare October 8, 2026 12:28
@github-actions github-actions Bot added kind/bug Categorizes issue or PR as related to a bug size/XS This PR changes 0-9 lines, ignoring generated files and removed size/L This PR changes 100-499 lines, ignoring generated files labels Oct 8, 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.

BingEdward (@7487) LGTM. The branch is now the one-line change: the edge listener gets its own edgeAllowedRoutes.DeepCopy(), same as edge-apex and the children. The trial merge with current main is clean, and go test ./internal/controller/tenantgateway passes on it. The PR body matches the diff.

The edge listener retained the renderer's local allowed-routes value,
while the apex and child listeners already owned independent copies.
Give edge the same ownership so later changes to the local value cannot
reach a rendered listener. The rendered Gateway remains unchanged.

Fixes cozystack#4118

Assisted-by: LLM
Signed-off-by: 7487 <[email protected]>
@lexfrei
Aleksei Sviridkin (lexfrei) force-pushed the fix/edge-listener-allowed-routes-aliasing branch from 7cf56fb to f2ec6af Compare October 11, 2026 15:52
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) kind/bug Categorizes issue or PR as related to a bug kind/cleanup Categorizes issue or PR as related to cleanup of code, process, or technical debt size/XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gateway: the edge listener shares its allowedRoutes pointer with the apex and child listeners

2 participants