feat: add orphaned downstream HTTPRoute GC controller#234
Closed
ecv wants to merge 2 commits into
Closed
Conversation
Add OrphanedDownstreamHTTPRouteGCReconciler, which scans Karmada for downstream HTTPRoutes that reference a Gateway that no longer exists on the upstream project cluster, and deletes them. This is a safety net for the pre-v0.23.6 bug where detachHTTPRoutes used Status.Parents instead of Spec.ParentRefs during gateway finalization (#231). Existing orphans left by that bug survive the v0.23.6 rollout because the finalizer already ran; this controller catches them on startup and on any subsequent event. Key design decisions: - Reconcile key is the upstream HTTPRoute identity (cluster+ns+name) derived from labels NSO stamps on every downstream HTTPRoute via SetControllerReference. No new indexes required. - Watches both upstream HTTPRoutes (deletions) and downstream HTTPRoutes (Karmada) so existing orphans are caught at startup via the initial informer list. - 5-minute minimum age threshold prevents deletion during Karmada propagation lag on healthy new routes. - A route with multiple parentRefs is only deleted when all referenced upstream Gateways are gone. Closes #233
Contributor
|
Seems like this is a bandaid for a garage collection issue? I wouldn't want to operationalize a bandaid. |
Contributor
Author
|
Mmm, we could delete the orphans from Karmada, but I'm preferring not to issue one-off administrative actions. I suppose we could develop a scripted admin process for deleting stuff from Karmada in the event we have to do so. But, shouldn't the component take care of them? The underlying orphan-creator has (probably) been fixed. |
Adding OrphanedDownstreamHTTPRouteGCReconciler pushed NewCommand's cyclomatic complexity to 61, exceeding the 60 limit. Extract the RunE body into a named runManager function, moving the complexity out of NewCommand. Introduce managerConfig struct to pass flag values cleanly. Rename inner cfg (rest.Config) to restCfg to avoid shadowing the parameter.
Contributor
Author
|
Doesn't seem like the most sane implementation. |
Contributor
Author
|
Closing as won't-do, sense of group is we do this as a one-off. |
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
OrphanedDownstreamHTTPRouteGCReconcilerthat scans Karmada (downstream cluster) for HTTPRoutes that reference a Gateway which no longer exists on the upstream project cluster, and deletes themMotivation
The v0.23.5 bug fixed in #231 (
detachHTTPRoutesusingStatus.Parents) could leave downstream HTTPRoutes alive on Karmada even after the upstream Gateway was deleted. Since the finalizer already ran, those orphans survive the v0.23.6 rollout and need a separate scan-and-delete pass. They also causeHTTPRouteStatusWarning/BackendNotFoundalerts that fire indefinitely with no auto-heal.Incident: datum-cloud/infra#2901, datum-cloud/engineering#330
Test plan
TestOrphanedDownstreamHTTPRouteGC/orphaned_route_deleted_when_upstream_gateway_missingTestOrphanedDownstreamHTTPRouteGC/healthy_route_not_deleted_when_upstream_gateway_existsTestOrphanedDownstreamHTTPRouteGC/young_route_not_deleted;_requeue_returnedTestOrphanedDownstreamHTTPRouteGC/route_with_multiple_parentRefs_kept_if_any_gateway_still_existsTestOrphanedDownstreamHTTPRouteGC/no_downstream_routes_is_a_no-opgo test ./internal/controller/...)tunnel-858j6is cleaned up after this ships (datum-cloud/infra#2901)Closes #233