Skip to content

PMREQ-821: Gateway access-grant finalizer and UIGateway extension - #5293

Open
vara2504 wants to merge 4 commits into
tigera:masterfrom
vara2504:vara-PMREQ-821-gateway-finalizer
Open

PMREQ-821: Gateway access-grant finalizer and UIGateway extension#5293
vara2504 wants to merge 4 commits into
tigera:masterfrom
vara2504:vara-PMREQ-821-gateway-finalizer

Conversation

@vara2504

@vara2504 vara2504 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-ups from the #5146 review (Whisker CIG), both requested by @caseydavenport:

1. A finalizer replaces delete-ordering for the gateway access grants (r3816269564). The access Role/RoleBinding were protected only by their position in the deletion list — emitted last so the operator kept its own write grant while deleting the Gateway/HTTPRoute/Backend. A failed or reordered delete could strip the grant first and orphan those resources. Both grants now carry operator.tigera.io/gateway-rbac-finalizer; teardown deletes only mark them, and a sweep in the uigateway helper removes the finalizer once the resources they cover are gone. The sweep discovers grants by the gateway label, so a grant that outlives its Gateway is still found and can never wedge. Uses Update rather than Patch: the operator's ClusterRole grants update on roles/rolebindings but not patch. No RBAC changes needed.

2. The Enterprise-only gateway objects move behind a UIGateway extension (r3883122289). The WAF filter ServiceAccount/RoleBinding reached the shared render as a raw ExtraProxyObjects pass-through the manager controller built by hand, mirrored across the create and delete paths. A UIGatewayExtension in the variant extension set replaces that; the Enterprise implementation returns the WAF objects for the Manager prefix and nothing for other components, so behavior is unchanged on every variant.

Also adds BackendName, ReferenceGrantName and ListenerName helpers so each generated name has one definition (follow-up to the earlier "brittle string" comment).

Testing: unit tests for the finalizer stamping, the sweep's gating (clears only marked grants whose resources are gone), and the extension flow. Verified end to end on a GKE Enterprise cluster: enable → Gateway Programmed, grants carry the finalizer, WAF objects present, UI serves HTTP 200 through the gateway; teardown → all gateway objects and grants removed in one reconcile cycle, nothing left Terminating; the sweep also recovered grants deliberately wedged by an earlier build.

This PR was written in part with the assistance of generative AI.

Release Note

Ingress gateway teardown protects its RBAC grants with a finalizer instead of delete ordering, so a partially failed teardown can no longer orphan gateway resources.

The access Role/RoleBinding were protected only by delete ordering:
emitted last so the operator kept its own write grant while deleting
the gateway resources. A failed or reordered delete could strip the
grant first and orphan them.

Both grants now carry operator.tigera.io/gateway-rbac-finalizer.
Teardown deletes only mark them; a sweep in the uigateway helper
clears the finalizer once the Gateway, HTTPRoute, Backend and
ReferenceGrant in that namespace are gone. The sweep lists grants by
the gateway label, so a grant that outlives its Gateway is still
found and never wedges.

Also adds BackendName, ReferenceGrantName and ListenerName helpers so
generated names have one definition each.

Follow-on from tigera#5146 review.
…nsion

The WAF filter ServiceAccount/RoleBinding reached the gateway render as a
raw ExtraProxyObjects pass-through: the manager controller built them by
hand and the create and delete paths each carried the field.

A UIGatewayExtension in the variant extension set replaces that. The
Enterprise implementation returns the WAF objects for the Manager prefix
and nothing for other components, so behavior is unchanged on every
variant. The uigateway Helper takes the extension and feeds one
proxyObjects() result to the render and both deletion paths, removing
the mirrored wiring. ExtraProxyObjects is gone from the shared Config.

Follow-on from tigera#5146 review.
The operator's ClusterRole grants update on roles and rolebindings but
not patch, so the finalizer sweep's Patch was forbidden and marked
grants never finished deleting. Unit tests missed it: the fake client
enforces no RBAC.

Verified on a GKE Enterprise cluster: the fixed sweep cleared grants
wedged by the old code, and a fresh enable/teardown cycle left nothing
behind.
@vara2504
vara2504 requested a review from a team as a code owner September 1, 2026 20:24
Copilot AI lite review requested due to automatic review settings September 1, 2026 20:24
@marvin-tigera marvin-tigera added this to the v1.45.0 milestone Sep 1, 2026

Copilot AI left a comment

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.

Pull request overview

This PR hardens UI ingress-gateway teardown by introducing an RBAC finalizer for per-namespace gateway access grants, and replaces ad-hoc Enterprise-only “extra proxy objects” plumbing with a formal UIGatewayExtension hook.

Changes:

  • Add operator.tigera.io/gateway-rbac-finalizer to gateway access Role/RoleBinding and implement a uigateway sweep to remove it once covered gateway resources are gone.
  • Introduce extensions.UIGatewayExtension and wire Enterprise’s WAF proxy-side objects through the extension (removing controller-side passthrough).
  • Centralize generated gateway-related names (BackendName, ReferenceGrantName, ListenerName) to avoid brittle string duplication.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/uigateway/uigateway.go Adds extension plumbing and RBAC-finalizer sweep to safely complete RBAC grant deletion.
pkg/uigateway/uigateway_test.go Adds unit tests for extension flow and RBAC finalizer clearing behavior.
pkg/render/gateway/component.go Defines RBAC finalizer constant, stamps grants, and centralizes gateway-related naming helpers.
pkg/render/gateway/component_test.go Verifies RBAC finalizer is stamped onto access Role/RoleBinding.
pkg/extensions/uigateway.go Introduces the UIGatewayExtension interface and a noop implementation.
pkg/extensions/extensions.go Adds UIGateway() accessor with a default noop implementation.
pkg/enterprise/uigateway/uigateway.go Implements the Enterprise UIGateway extension (WAF objects only for Manager prefix).
pkg/enterprise/register.go Registers the Enterprise UIGateway extension in the extension set.
pkg/enterprise/controller/manager/manager_controller.go Switches Manager gateway helper construction to use the UIGateway extension hook.
pkg/controller/whisker/controller.go Plumbs the UIGateway extension into Whisker’s gateway helper construction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/uigateway/uigateway.go Outdated
Comment on lines +356 to +359
var noMatch *apimeta.NoKindMatchError
if !errors.IsNotFound(err) && !stderrors.As(err, &noMatch) {
return false, err
}
accessResourcesGone suppressed only NoKindMatchError, so a
NoResourceMatchError from the mapper would block finalizer clearing.
apimeta.IsNoMatchError covers both. Review follow-up on tigera#5293.
Copilot AI review requested due to automatic review settings September 1, 2026 20:58

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@caseydavenport caseydavenport self-assigned this Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants