refactor(networking): use typed gateway-api client for HTTPRoute#316
Merged
Conversation
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
3881bf3 to
07bfde0
Compare
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
Replaces the unstructured/map[string]any construction of HTTPRoute resources with the typed sigs.k8s.io/gateway-api v1 client. Same wire behavior, cleaner code, compile-time field validation, and a foundation for typed envtest assertions in upcoming Phase 1 work. Changes - networking.go: HTTPRoute construction (`generateHTTPRoute`), list operations (`deleteHTTPRoutesByLabel`, `deleteOrphanedHTTPRoutes`, `orphanNetworkingResources` HTTPRoute branch) all converted to *gatewayv1.HTTPRoute / *gatewayv1.HTTPRouteList. Apply-patch path unchanged (still SSA via client.Patch). The CRDNotInstalled graceful degradation continues to work: typed client returns the same meta.IsNoMatchError when the apiserver doesn't recognize the kind. - Drops three now-dead helpers: httpRouteGVK(), deleteUnstructured() (was already orphaned), toStringInterfaceMap(). - cmd/main.go: register gatewayv1.Install on the manager scheme so the typed client knows the kind. - networking_test.go: rewrites assertions to typed field access (route.Spec.ParentRefs[0].Name, route.Spec.Rules[i].BackendRefs[0].Port etc.) instead of navigating map[string]any. Test intent is unchanged. - plan_test.go: adds gatewayv1.Install to the shared test scheme so fake-client List(HTTPRouteList) succeeds for tests that exercise the networking teardown path. Adds sigs.k8s.io/gateway-api v1.5.1 as a direct dep (it was already an indirect dep via controller-runtime; net new transitive surface is minimal). go build ./... and go test ./... both green.
07bfde0 to
74dac1b
Compare
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
3 tasks
bdchatham
added a commit
that referenced
this pull request
May 21, 2026
…TTPRoute (#322) Follow-up to #316. Two regression-armor tests the Coral review surfaced as load-bearing but didn't make it into the original PR. - TestGenerateHTTPRoute_TypeMeta: asserts APIVersion + Kind are populated on the typed object. The SSA apply path relies on these top-level keys matching what the unstructured builder produced pre-#316; an empty TypeMeta would silently break server-side apply. - TestGenerateHTTPRoute_BackendRefDefaultsServerSide: asserts every BackendObjectReference leaves Group and Kind nil. Setting them explicitly would cause field-manager "seinode-controller" to claim those paths via SSA, fighting any future operator who tries to retarget a backend. Locks down the no-server-default-claim invariant the Coral k8s-specialist flagged in their finding #5. Test-only change. go test ./... green.
8 tasks
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.
Summary
Replaces the unstructured /
map[string]anyHTTPRoute construction ininternal/controller/nodedeployment/networking.gowith the typedsigs.k8s.io/gateway-api/apis/v1client. Same wire behavior, cleaner code, compile-time field validation, and a typed foundation for envtest assertions in the upcoming Phase 1 work.Net: 6 files, +127 / -143.
Why
map[string]anyingenerateHTTPRoute()is a typo waiting to happen — any field-name change in the gateway-api spec lands as a silent runtime no-op.route.Object["spec"].(map[string]any)["rules"].([]any)[0]...toroute.Spec.Rules[0]— both writing and reading test code becomes orders of magnitude cleaner.httpRouteGVK(),deleteUnstructured()(which was already orphaned with zero callers), andtoStringInterfaceMap().Changes
internal/controller/nodedeployment/networking.gogenerateHTTPRoutereturns*gatewayv1.HTTPRoute;deleteHTTPRoutesByLabel/deleteOrphanedHTTPRoutes/orphanNetworkingResourcesHTTPRoute branch use*gatewayv1.HTTPRouteList. Three dead helpers removed. SSA apply path unchanged.cmd/main.goutilruntime.Must(gatewayv1.Install(scheme))— required so the typed client knows the kind at runtime.internal/controller/nodedeployment/networking_test.gointernal/controller/nodedeployment/plan_test.gonewPlanTestScheme) addsgatewayv1.Installso fake-clientList(HTTPRouteList)succeeds in tests that exercise the networking teardown path.go.mod/go.sumsigs.k8s.io/gateway-api v1.5.1as a direct dep (was already an indirect dep via controller-runtime; net new transitive surface is minimal).Behavior preservation
CRDNotInstalledgraceful degradation still works: when the cluster doesn't have the gateway-api CRDs installed, the typed client surfaces the samemeta.IsNoMatchErrorfrom the apiserver that the unstructured client did. The existing condition-flip + event remain.client.Patch(..., client.Apply, fieldOwner, client.ForceOwnership)call site, same field manager.apiVersion: gateway.networking.k8s.io/v1, same fields, same defaults).Test plan
go build ./...exits 0go test ./...exits 0 (all 8 test-bearing packages pass)TestGenerateHTTPRoute_*tests pass against typed assertionsTestInternalService_SurvivesNetworkingTeardown(which exercisesdeleteHTTPRoutesByLabelagainst a fake client) passes after registeringgatewayv1in the shared test schemeFollow-up
This unblocks envtest Phase 1 — the planned
TestInPlaceRollout_EndToEndand future networking assertions get typed access from day one. No vendoring of gateway-api CRDs needed for tests that don't setspec.networking; future networking-aware tests will install the CRDs into envtest's apiserver viaCRDDirectoryPaths.🤖 Generated with Claude Code