agent: delete unreferenced helpers and unread constants - #679
Open
Philip Lombardi (plombardi89) wants to merge 1 commit into
Open
agent: delete unreferenced helpers and unread constants#679Philip Lombardi (plombardi89) wants to merge 1 commit into
Philip Lombardi (plombardi89) wants to merge 1 commit into
Conversation
Straight zero-reference removals:
- attest.CleanupAttestArtifacts
- provision.ResolveDownloadOverrides
- utilio.CleanDir, utilio.DecompressTarGzFromRemote and the private
downloadFromRemote it wrapped. Removing them left remoteHTTPClient with no
reader, which `unused` then reported - the linter can see the cascade once
the exported entry point is gone, which is the whole shape of the problem
this series is about.
- phases/host.CheckHostPackages
goalstates.ContainerImageArchivePath took an index and had no caller. It is not
the bootstrapartifacts.ContainerImageArchivePath of the same name, which takes
(arch, imageTag) and is called from offline_artifacts.go and the artifacts
builder. Only the goalstates one is removed.
agentbinary.installFromTarGz had no caller either. It is not the body of
InstallAndSwitchFromTarGz, which does its own download and extraction; the two
had diverged. Its two tests, TestInstallFromTarGzVerifiesInstalledBinary and
TestInstallFromTarGzRejectsUnsupportedScheme, were the only callers and go with
it. TestInstallAndSwitchFromTarGz still covers the live path.
Constants:
- config.DefaultLocalDNSMetricsPort is a string "9253" duplicating
goalstates.LocalDNSMetricsPort, which is the int the code actually uses.
- goalstates.KubeletPKIDir had no reader and the literal
"/etc/kubernetes/pki" appears nowhere else in the tree.
Three constants that the analyzers report are kept, with a comment saying why,
because their consumers are not Go:
- LocalDNSCorefilePath and LocalDNSUpstreamsPath are hardcoded in
pkg/agent/phases/rootfs/assets/localdns-supervisor.sh.
- LocalDNSRuleComment is asserted by hack/agent/e2e-kind/e2e.py.
Neither analyzer sees across the language boundary, so "no caller" there means
"no Go caller". That is a different claim, and deleting on it would have
removed the only in-tree record of an interface the shell script depends on.
pkg/agent/daemon is deliberately untouched. NewMachinaMachineOperationReconciler
and NoopMachineOperationReconciler are test-only, but they are exported from
pkg/, not internal/, so the module is not the closed world for them that it is
for internal/.
Refs #670
This was referenced Aug 26, 2026
Member
|
Inspected Result: no AKSFlexNode reference depends on any removed Unbounded API.
No branch changes were made. |
hbc (bcho)
approved these changes
Aug 26, 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.
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
unusedcannot see dead exported code underinternal/. That is a documented design decision, not a gap:unused/unused.go:48-62holds 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/deadcodedoes 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. Onevar i any = xanywhere buys all ofx's exported methods a clean bill of health.So #673 adds both
deadcodeandhack/cmd/unreferenced, which resolves identifiers instead of tracing reachability. Neither subsumes the other, and findings below are attributed to whichever one saw them.agent: delete unreferenced helpers and unread constants
Straight zero-reference removals:
downloadFromRemote it wrapped. Removing them left remoteHTTPClient with no
reader, which
unusedthen reported - the linter can see the cascade oncethe exported entry point is gone, which is the whole shape of the problem
this series is about.
goalstates.ContainerImageArchivePath took an index and had no caller. It is not
the bootstrapartifacts.ContainerImageArchivePath of the same name, which takes
(arch, imageTag) and is called from offline_artifacts.go and the artifacts
builder. Only the goalstates one is removed.
agentbinary.installFromTarGz had no caller either. It is not the body of
InstallAndSwitchFromTarGz, which does its own download and extraction; the two
had diverged. Its two tests, TestInstallFromTarGzVerifiesInstalledBinary and
TestInstallFromTarGzRejectsUnsupportedScheme, were the only callers and go with
it. TestInstallAndSwitchFromTarGz still covers the live path.
Constants:
goalstates.LocalDNSMetricsPort, which is the int the code actually uses.
"/etc/kubernetes/pki" appears nowhere else in the tree.
Three constants that the analyzers report are kept, with a comment saying why,
because their consumers are not Go:
pkg/agent/phases/rootfs/assets/localdns-supervisor.sh.
Neither analyzer sees across the language boundary, so "no caller" there means
"no Go caller". That is a different claim, and deleting on it would have
removed the only in-tree record of an interface the shell script depends on.
pkg/agent/daemon is deliberately untouched. NewMachinaMachineOperationReconciler
and NoopMachineOperationReconciler are test-only, but they are exported from
pkg/, not internal/, so the module is not the closed world for them that it is
for internal/.
Refs #670
Verification
go build ./...,go vet ./...,golangci-lintover the touched trees (0 issues),make fmtproducing no diff, andgo 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.