[2.3] fix: Do not mutate a Service kgateway does not own.#14351
Merged
davidjumani merged 2 commits intoJul 10, 2026
Merged
Conversation
Signed-off-by: David L. Chandler <[email protected]> (cherry picked from commit fb8b18f)
Contributor
There was a problem hiding this comment.
Pull request overview
This backport hardens the Gateway deployer to avoid accidentally taking over and patching an existing Kubernetes Service that wasn’t created/owned by kgateway, addressing the “Gateway name collides with Service name” scenario from #13499.
Changes:
- Add a Service-ownership guard in the deployer to refuse patching an existing Service unless it is proven to be owned (controller ownerRef or matching kgateway ownership labels).
- Add deployer unit tests covering allowed/denied patch scenarios for existing Services.
- Improve E2E stability in the multiinstall suite by making the access-log polling more tolerant and increasing the timeout.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/e2e/features/multiinstall/suite.go | Makes log polling assertions non-fatal per retry and increases polling timeout. |
| pkg/kgateway/helm/envoy/templates/service.yaml | Minor Helm template formatting adjustment (no functional change). |
| pkg/deployer/deployer.go | Adds Service ownership validation before patching an existing Service. |
| pkg/deployer/deployer_test.go | Adds tests for refusing/allowing patch based on ownership signals. |
Comment on lines
285
to
+289
| // If the object doesn't exist or there's an error other than "not found", proceed with patching | ||
| switch { | ||
| case err == nil: | ||
| if err := validateExistingServiceOwnership(sourceObj, obj, existing); err != nil { | ||
| return err |
davidjumani
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #14145 to
v2.3.x.Description
Fixes #13499.
kgateway now refuses to patch an existing Gateway
Serviceunless theServiceproves ownership through either:ownerReferencefor the sourceGatewayapp.kubernetes.io/managed-by: kgatewaygateway.networking.k8s.io/gateway-class-namegateway.networking.k8s.io/gateway-nameorgateway.kgateway.dev/gateway-full-nameThis prevents accidental takeover of unrelated Services with the same name as a Gateway.
Upgrade behavior
2.2.0
ownerReferenceand kgateway labels.2.3.0, main
Change Type
/kind fix
Changelog
Additional Notes