OCPBUGS-83863: Strip debug symbols from Go binaries#1525
Conversation
Add -s -w to ldflags to strip DWARF debug info and symbol tables. This typically reduces binary size by 20-30%, which reduces container image pull time during node scale-up. Also fix build-gather-sysinfo and build-performance-profile-creator targets which intended to strip but had a make-vs-shell variable expansion bug: they set a shell variable LDFLAGS then referenced $(LDFLAGS) which make expands (to empty) before the shell runs. rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
|
@sdodson: This pull request references Jira Issue OCPBUGS-83863, which is valid. 3 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe Makefile adds Go linker strip flags ( ChangesBinary size optimization via Go linker flags
🎯 2 (Simple) | ⏱️ ~10 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Thank you for the PR, Scott. Do we want to do the same thing for |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
|
Good call, done — added |
|
The gzipped binary is about half as large once stripped. |
|
/retest |
1 similar comment
|
/retest |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jmencak, sdodson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/verified by CI |
|
@sdodson: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/retest |
|
@sdodson: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@sdodson: Jira Issue OCPBUGS-83863: Some pull requests linked via external trackers have merged: The following pull request, linked via external tracker, has not merged:
All associated pull requests must be merged or unlinked from the Jira bug in order for it to move to the next state. Once unlinked, request a bug refresh with Jira Issue OCPBUGS-83863 has not been moved to the MODIFIED state. This PR is marked as verified. If the remaining PRs listed above are marked as verified before merging, the issue will automatically be moved to VERIFIED after all of the changes from the PRs are available in an accepted nightly payload. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Summary
-s -wto ldflags inGO_BUILD_RECIPEto strip DWARF debug info and symbol tables from the main operator binarybuild-gather-sysinfoandbuild-performance-profile-creatortargets which intended to strip but had a make-vs-shell variable expansion bug ($(LDFLAGS)is expanded by make before the shell runs, so the shell variable set on the previous line was never used)Impact
The cluster-node-tuning-operator image (617 MB) contains three unstripped Go binaries totaling 195 MB:
cluster-node-tuning-operator(96.8 MB)gather-sysinfo(63.8 MB)performance-profile-creator(34.6 MB)Stripping typically reduces Go binary size by 20-30%, reducing container image pull time during node scale-up.
Test plan
file /usr/bin/cluster-node-tuning-operatorshould show "stripped")Summary by CodeRabbit