Skip to content

net: delete the superseded node-CIDR controller - #676

Open
Philip Lombardi (plombardi89) wants to merge 1 commit into
mainfrom
chore/deadcode-net-controller
Open

net: delete the superseded node-CIDR controller#676
Philip Lombardi (plombardi89) wants to merge 1 commit into
mainfrom
chore/deadcode-net-controller

Conversation

@plombardi89

Copy link
Copy Markdown
Collaborator

Part of the #670 dead-code sweep, split by component. The tooling that produced these findings is #673; this PR is deletions only and is independent of the other eight — the file sets are disjoint, so they can be reviewed and merged in any order and in parallel.

Why two analyzers were needed to find this

unused cannot see dead exported code under internal/. That is a documented design decision, not a gap: unused/unused.go:48-62 holds that a package uses its exported named types and a named type uses its exported methods, so every method on an exported type is transitively live because the type is exported.

x/tools/cmd/deadcode does not close that gap on its own either. x/tools/go/callgraph/rta/rta.go:281-287,433-437 — converting a value to an interface materializes its runtime type and marks every exported method of that type reachable, because reflection could call any of them. One var i any = x anywhere buys all of x's exported methods a clean bill of health.

So #673 adds both deadcode and hack/cmd/unreferenced, which resolves identifiers instead of tracing reachability. Neither subsumes the other, and findings below are attributed to whichever one saw them.


net: delete the superseded node-CIDR controller

internal/net/controller/controller.go is a 542-line Kubernetes node controller
that allocates pod CIDRs per node. Nothing constructs it. Its package is
imported by cmd/unbounded-net-controller, which is what kept it out of every
previous sweep, but the symbols that import reaches are NewSiteController,
NewGatewayPoolController, NewPeeringAggregationController,
NewManagedKubeProxyController, ManagedKubeProxyOptions, NodeSiteLabel,
TunnelMTUAnnotation and WireGuardPubKeyAnnotation. Not Controller.

Without -test, make deadcode reports every one of its methods unreachable:
InformerSynced, NewController, enqueueNode, matchesNodeFilter, Run, runWorker,
processNextWorkItem, syncHandler, allocateCIDRsForNode, patchNodeCIDRs,
InitializeAllocator and DryRun. With -test, four remain unreachable, and the
only thing holding the rest up is controller_helpers_test.go, whose five tests
exist for no other purpose. Site-based pod CIDR assignment superseded this; the
live path is SiteController.buildAssignmentAllocator.

The file and its test go together. Keeping the tests would have kept twelve
dead methods alive and moved them from one section of the report to the other.

This is the one deletion in the series where intent is inferred from the call
graph rather than read from a document. If there is a plan to revive this
controller, this is the commit to push back on.

The cascade:

  • allocator.ContainsCIDR had no caller at all.
  • allocator.ParseCIDRs had no caller in production. Both live callers of
    NewAllocator - site_controller.go and webhook/validation.go - build their
    pools with splitCIDRBlocks. It was exported API kept alive entirely by
    allocator_test.go, so it moves into that file as an unexported helper and
    the tests are unchanged apart from the name.
  • computeReachableRoutes was a two-line wrapper around computeReachable
    called only from peering_aggregation_controller_test.go. The wrapper goes
    and the test calls computeReachable directly, which is what it was actually
    exercising.
  • SiteController.GetSiteForNode had no reference anywhere.

The three unobserved promauto metric vars in controller/metrics.go are
deliberately left alone; they are tracked in #672.

Refs #670


Verification

go build ./..., go vet ./..., golangci-lint over the touched trees (0 issues), make fmt producing no diff, and go build -tags e2e,integrationtest,storageboundary ./.... Full suite runs in CI.

The eight deletion branches were reassembled onto the tooling commits and diffed against the original combined branch: byte-identical, so nothing was lost or duplicated in the split.

internal/net/controller/controller.go is a 542-line Kubernetes node controller
that allocates pod CIDRs per node. Nothing constructs it. Its package is
imported by cmd/unbounded-net-controller, which is what kept it out of every
previous sweep, but the symbols that import reaches are NewSiteController,
NewGatewayPoolController, NewPeeringAggregationController,
NewManagedKubeProxyController, ManagedKubeProxyOptions, NodeSiteLabel,
TunnelMTUAnnotation and WireGuardPubKeyAnnotation. Not Controller.

Without -test, `make deadcode` reports every one of its methods unreachable:
InformerSynced, NewController, enqueueNode, matchesNodeFilter, Run, runWorker,
processNextWorkItem, syncHandler, allocateCIDRsForNode, patchNodeCIDRs,
InitializeAllocator and DryRun. With -test, four remain unreachable, and the
only thing holding the rest up is controller_helpers_test.go, whose five tests
exist for no other purpose. Site-based pod CIDR assignment superseded this; the
live path is SiteController.buildAssignmentAllocator.

The file and its test go together. Keeping the tests would have kept twelve
dead methods alive and moved them from one section of the report to the other.

This is the one deletion in the series where intent is inferred from the call
graph rather than read from a document. If there is a plan to revive this
controller, this is the commit to push back on.

The cascade:

  - allocator.ContainsCIDR had no caller at all.
  - allocator.ParseCIDRs had no caller in production. Both live callers of
    NewAllocator - site_controller.go and webhook/validation.go - build their
    pools with splitCIDRBlocks. It was exported API kept alive entirely by
    allocator_test.go, so it moves into that file as an unexported helper and
    the tests are unchanged apart from the name.
  - computeReachableRoutes was a two-line wrapper around computeReachable
    called only from peering_aggregation_controller_test.go. The wrapper goes
    and the test calls computeReachable directly, which is what it was actually
    exercising.
  - SiteController.GetSiteForNode had no reference anywhere.

The three unobserved promauto metric vars in controller/metrics.go are
deliberately left alone; they are tracked in #672.

Refs #670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant