Repository navigation
Fast-path provisioning: per-Gateway LoadBalancer Services and per-Gateway ports - #624
Conversation
| if err := r.Get(ctx, req.NamespacedName, gw); err != nil { | ||
| if apierrors.IsNotFound(err) { | ||
| if cleaner, ok := r.AddressProvider.(AddressCleaner); ok { | ||
| _ = cleaner.DeleteGateway(ctx, req.NamespacedName) |
There was a problem hiding this comment.
I think we should at least log the error, if we can't handle it.
|
|
||
| if !r.inScope(gw) { | ||
| if cleaner, ok := r.AddressProvider.(AddressCleaner); ok { | ||
| _ = cleaner.DeleteGateway(ctx, req.NamespacedName) |
There was a problem hiding this comment.
I think we should at least log the error, if we can't handle it.
| // AddressCleaner is an optional interface that an AddressProvider can implement | ||
| // to clean up resources when a Gateway is deleted. | ||
| type AddressCleaner interface { | ||
| DeleteGateway(ctx context.Context, gw types.NamespacedName) error |
There was a problem hiding this comment.
Let's rename to OnGatewayDeleted or something more self-descriptive
|
|
||
| if string(gc.Spec.ControllerName) != controllerName { | ||
| if cleaner, ok := r.AddressProvider.(AddressCleaner); ok { | ||
| _ = cleaner.DeleteGateway(ctx, req.NamespacedName) |
|
Thanks for this. It works, but reviewing it made it clear that dynamic per-Gateway pod ports put too much test-only complexity into the data plane. We've changed the design to one data-plane Deployment per Gateway; see #620 (latest comment). Please rework this PR to that design (or close it and open a new one, whichever is easier):
Points from my earlier review that still apply:
|
Address review feedback on gke-labs#624: - Provision a dedicated data-plane Deployment per Gateway in pkg/provisioning/singlepod selecting its own LoadBalancer Service. - Support data-plane mode in GARI with GatewayFilter and DisableStatusUpdates. - Derive Service ports from Gateway effective listeners (including ListenerSets). - Gate Programmed condition on Deployment availability and Service LoadBalancer address assignment without fallback. - Implement label-based orphan sweeping and deletion cleanup via GatewayDeleteHandler.OnGatewayDeleted. - Drop dynamic listener manager, port allocator, scoped proxy, and Gateway finalizer. Fixes gke-labs#620
|
Thanks for the rework. The architecture now matches the #620 design: a Deployment and a Before we merge, there are some bugs and regressions to fix, plus some unrelated churn to revert: Bugs and regressions
Smaller points
Unrelated churn (please revert)
Process
|
337c577 to
25008be
Compare
|
Heads-up: #629 (incremental state step 2) is merging and changes the code this PR touches. Please rebase onto
The points from my previous review still apply: the Namespace and ReferenceGrant watch regressions disappear with #629, but cleanup errors, foreign-Gateway DELETEs, the readiness probe, the |
) Implement step 1b of gke-labs#587 for fast-path single-pod mode: - Create dedicated per-Gateway LoadBalancer Service and Deployment in the controller namespace with deterministic names and labels in pkg/provisioning/singlepod. - Derive Service ports from Gateway effective listeners (including ListenerSets) via State outputs. - Add data-plane mode in pkg/gari and cmd/gateway-api-reference-implementation with GatewayFilter and DisableStatusUpdates. - Integrate data-plane Deployment availability into State.SetGatewayReadiness, gating Gateway Programmed condition on Deployment availability and LoadBalancer address assignment without fallback. - Provide separate read-only gari-dataplane ServiceAccount, ClusterRole, and ClusterRoleBinding for data-plane pods. - Implement label-based orphan sweep and deletion cleanup via GatewayDeleteHandler.OnGatewayDeleted with error handling and requeue. - Remove shared gari-proxy Service from k8s/controller.yaml, grant Deployment and Service CRUD in controller ClusterRole, and update e2e harness/tests to use Gateway status.addresses. - Enable HTTPRouteMultipleGateways in conformance tests. Fixes gke-labs#620
25008be to
6c24281
Compare
|
Follow-up on where the per-Gateway resources live, prompted by filing #635 (GatewayInfrastructure). Decision: provision the data-plane Deployment and Service into the Gateway's namespace, not the controller namespace.
RBAC caveat, and we must address it before this is safe outside test clusters:
The earlier round-2 points and the rebase-on-#629 note still apply. |
Address review feedback on gke-labs#624: - Provision per-Gateway ServiceAccount, Deployment, and LoadBalancer Service in the Gateway's own namespace named <gateway-name>-gari. - Set ownerReference pointing to the Gateway for automatic garbage collection on Gateway deletion. - Propagate spec.infrastructure.labels and spec.infrastructure.annotations onto provisioned resources. - Create read-only gari-dataplane ClusterRole bound to system:serviceaccounts and add security documentation for future per-Gateway secret push. - Update e2e tests to verify Service, Deployment, and ServiceAccount in Gateway namespace. Fixes gke-labs#620
|
Thanks for the quick turnaround. Moving to the Gateway namespace looks good overall, but there is one critical security problem and a few correctness issues. Several of these matter more now that we write into user namespaces. Must fix
Should fix (raised in round 2, still open)
Looks good
|
…isioning Address round-4 review feedback on gke-labs#624: - Create per-Gateway ClusterRoleBinding in the controller bound only to that Gateway's ServiceAccount. - Fix readiness gating bug in State.SetGatewayReadiness (check existing key before skipping) and cleanup readiness map on gateway delete/filter. - Add unit test for State.SetGatewayReadiness gating Programmed condition. - Add ownership checks and adoption in AddressProvider (verify OwnerReference or managed labels before updating or deleting, and reject foreign conflicts). - Apply user infrastructure labels first, ignore keys with gateway.networking.k8s.io/ prefix, and use GARI-specific selector labels (gateway-name + gari-dataplane). - Avoid unnecessary Deployment updates by tracking desired pod template spec SHA256 hash in annotation. - Update data-plane readiness check (/readyz) to pass only after State is synced and initial proxy config is applied. Fixes gke-labs#620
|
Thanks, this round fixes the previous must-fix items:
Remaining items:
|
…status on conflict Address round-5 review feedback on gke-labs#624: - Use a single shared gari-dataplane ClusterRoleBinding in k8s/controller.yaml with empty subjects. - Restrict controller RBAC to get/update/patch on clusterrolebindings with resourceNames: ["gari-dataplane"]. - Controller deterministically manages ServiceAccount subjects in the shared ClusterRoleBinding with conflict retry. - Hash full PodTemplateSpec (including metadata and labels) in annotation to trigger updates when infrastructure labels change. - Record provisioning conflict error on Gateway status (Programmed=False) and stop infinite requeue. - Clean up ClusterRoleBinding subjects in OnGatewayDeleted and SweepOrphans. Fixes gke-labs#620
|
Nearly there. Just two more things:
|
… error returns Address round-6 review feedback on gke-labs#624: - Define controller.OwnershipConflictError and return it from singlepod.AddressProvider on resource ownership conflicts. - In GatewayReconciler.Reconcile, record OwnershipConflictError on Gateway status (Programmed=False) without returning an error. - Return all other transient errors from GatewayReconciler.Reconcile so controller-runtime retries with exponential backoff. - Add unit test TestGatewayReconciler_ErrorHandling verifying transient error return vs OwnershipConflictError status recording. Fixes gke-labs#620
justinsb
left a comment
There was a problem hiding this comment.
LGTM, thanks! A few small leftovers will go into a follow-up issue.
Small follow-ups left over from the #624 review: - Remove unused ModelInputs.ManagedClassMatched field in pkg/state/compiled.go - Add status test for provisioning errors in pkg/state/state_test.go verifying Programmed=False with error message and restoring Programmed=True when cleared - Check ServiceAccount existence against the direct API reader in SweepOrphans to prevent removing newly created data-plane ServiceAccounts due to cache lag - Requeue Gateway on OwnershipConflictError after DefaultConflictRequeueDelay (1m) so resolved ownership conflicts are detected without waiting for resync Fixes #639
Provisioning follow-ups from #624
Fixes #620