Skip to content

Conversation

adrianmoisey
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Dead code causes the outputted Go binary to be larger. Upstream kubernetes recently put effort into ensuring that Kubernetes doesn't include dead code.
We should copy this, if reasonable to do so, to save storage and bandwidth costs.

Which issue(s) this PR fixes:

Fixes #8270

Special notes for your reviewer:

I've modified the verify script to run all verify-.shscripts for the VPA. It seems that the codegen hasn't been run in a while, which I'll fix in another PR

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianmoisey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from kgolab October 19, 2025 13:27
@k8s-ci-robot k8s-ci-robot requested a review from voelzmo October 19, 2025 13:27
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels Oct 19, 2025
@adrianmoisey adrianmoisey mentioned this pull request Oct 19, 2025
@jackfrancis
Copy link
Contributor

I know this is going to be annoying, but is there any way we could put this in the root hack/ directory and re-use between CA and VPA? CA has stuff, too

$ GOLDFLAGS=-dumpdep go build -C cluster-autoscaler -ldflags=-dumpdep -o cluster-autoscaler 2>&1 | grep "\->" | /Users/jackfrancis/go/bin/whydeadcode
text/template.(*state).evalField reachable from:
	 text/template.(*state).evalFieldChain
	 text/template.(*state).evalCommand
	 text/template.(*state).evalPipeline
	 text/template.(*state).walk
	 text/template.(*Template).execute
	 html/template.(*Template).Execute
	 golang.org/x/net/trace.RenderEvents
	 golang.org/x/net/trace.Events
	 golang.org/x/net/trace.Events·f
	 golang.org/x/net/trace.init.0
	 golang.org/x/net/trace..inittask
	 go:main.inittasks
	 _

k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.(*addressableValue).Method reachable from:
	 type:k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.addressableValue
	 type:func(k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions, *k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder, k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.addressableValue) error
	 type:k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.typedArshaler[k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions,k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder]
	 type:[]k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.typedArshaler[k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions,k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder]
	 type:k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.typedArshalers[k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions,k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder]
	 type:*k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.typedArshalers[k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions,k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder]
	 type:k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions
	 type:func(k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalOptions, *k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.Encoder) error
	 type:k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalerV2
	 type:*k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.MarshalerV2
	 k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.init
	 k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json..inittask
	 go:main.inittasks
	 _

github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta.(*ServiceInfo).Methods reachable from:
	 type:*github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta.ServiceInfo
	 github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta.init.0
	 github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta..inittask
	 go:main.inittasks
	 _

github.com/google/go-cmp/cmp/internal/value.appendTypeName reachable from:
	 github.com/google/go-cmp/cmp.formatOptions.FormatType
	 github.com/google/go-cmp/cmp.formatOptions.FormatDiff
	 github.com/google/go-cmp/cmp.(*defaultReporter).String
	 github.com/google/go-cmp/cmp.Diff
	 k8s.io/cloud-provider-gcp/providers/gce.(*Cloud).ensureInternalLoadBalancer
	 k8s.io/cloud-provider-gcp/providers/gce.(*Cloud).EnsureLoadBalancer
	 type:*k8s.io/cloud-provider-gcp/providers/gce.Cloud
	 type:k8s.io/cloud-provider-gcp/providers/gce.Cloud
	 k8s.io/cloud-provider-gcp/providers/gce.CreateGCECloud
	 k8s.io/cloud-provider-gcp/providers/gce.newGCECloud
	 k8s.io/cloud-provider-gcp/providers/gce.init.0.func1
	 k8s.io/cloud-provider-gcp/providers/gce.init.0.func1·f
	 k8s.io/cloud-provider-gcp/providers/gce.init.0
	 k8s.io/cloud-provider-gcp/providers/gce..inittask
	 go:main.inittasks
	 _

@adrianmoisey
Copy link
Member Author

I know this is going to be annoying, but is there any way we could put this in the root hack/ directory and re-use between CA and VPA?

My preference is to not do that, since the VPA and CA operate quite differently (ie: VPA has 3 binaries).
Given the simplicity of this script, I think duplicating it is fine

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow linker to perform dead code elimination

3 participants